-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Upgrade mypy to version 0.931 #12030
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Upgrade mypy to version 0.931. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
import signal | ||
import sys | ||
from types import FrameType, TracebackType | ||
from typing import NoReturn, Type | ||
from typing import NoReturn, Optional, Type | ||
|
||
|
||
def daemonize_process(pid_file: str, logger: logging.Logger, chdir: str = "/") -> None: | ||
|
@@ -100,7 +100,9 @@ def daemonize_process(pid_file: str, logger: logging.Logger, chdir: str = "/") - | |
# also catch any other uncaught exceptions before we get that far.) | ||
|
||
def excepthook( | ||
type_: Type[BaseException], value: BaseException, traceback: TracebackType | ||
type_: Type[BaseException], | ||
value: BaseException, | ||
traceback: Optional[TracebackType], | ||
) -> None: | ||
logger.critical("Unhanded exception", exc_info=(type_, value, traceback)) | ||
|
||
|
@@ -123,7 +125,7 @@ def excepthook( | |
sys.exit(1) | ||
|
||
# write a log line on SIGTERM. | ||
def sigterm(signum: signal.Signals, frame: FrameType) -> NoReturn: | ||
def sigterm(signum: int, frame: Optional[FrameType]) -> NoReturn: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
logger.warning("Caught signal %s. Stopping daemon." % signum) | ||
sys.exit(0) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
import functools | ||
import sys | ||
from typing import Any, Callable, Generator, List, TypeVar | ||
from typing import Any, Callable, Generator, List, TypeVar, cast | ||
|
||
from twisted.internet import defer | ||
from twisted.internet.defer import Deferred | ||
|
@@ -174,7 +174,9 @@ def check_yield_points_inner( | |
) | ||
) | ||
changes.append(err) | ||
return getattr(e, "value", None) | ||
# The `StopIteration` or `_DefGen_Return` contains the return value from the | ||
# generator. | ||
return cast(T, e.value) | ||
Comment on lines
-177
to
+179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both of the exception types we catch here have a class StopIteration(Exception):
value: Any
class _DefGen_Return(BaseException):
def __init__(self, value: object) -> None:
self.value = value Since the exception comes from the generator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Seems plausible: https://github.com/twisted/twisted/blob/5c24e99e671c4082a1ddc8dbeb869402294bd0dc/src/twisted/internet/defer.py#L1508-L1521 |
||
|
||
frame = gen.gi_frame | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to https://github.com/python/typeshed/pull/6678/files?