You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, according to PEP 484, __init__ methods need to be marked as if they return None.
(Note that the return type of init ought to be annotated with -> None. The reason for this is subtle. If init assumed a return annotation of -> None, would that mean that an argument-less, un-annotated init method should still be type-checked? Rather than leaving this ambiguous or introducing an exception to the exception, we simply say that init ought to have a return annotation; the default behavior is thus the same as for other methods.)
In my code I have a custom formatter that derives JsonFormatter and calls super().__init__, but the lack of types triggers mypy. I can "solve" this on my end by adding a # type: ignore, but it's such a low hanging fruit that it's probably worth adding it here.
I'm willing to make a PR for this
The text was updated successfully, but these errors were encountered:
SpyrosRoum
changed the title
Makr JsonFormatter's __init__ to return None
Mark JsonFormatter's __init__ to return None
Apr 4, 2023
Hello, according to PEP 484,
__init__
methods need to be marked as if they returnNone
.In my code I have a custom formatter that derives JsonFormatter and calls
super().__init__
, but the lack of types triggers mypy. I can "solve" this on my end by adding a# type: ignore
, but it's such a low hanging fruit that it's probably worth adding it here.I'm willing to make a PR for this
The text was updated successfully, but these errors were encountered: