Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark JsonFormatter's __init__ to return None #173

Open
SpyrosRoum opened this issue Apr 4, 2023 · 1 comment · May be fixed by #174
Open

Mark JsonFormatter's __init__ to return None #173

SpyrosRoum opened this issue Apr 4, 2023 · 1 comment · May be fixed by #174

Comments

@SpyrosRoum
Copy link

SpyrosRoum commented Apr 4, 2023

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

@SpyrosRoum SpyrosRoum changed the title Makr JsonFormatter's __init__ to return None Mark JsonFormatter's __init__ to return None Apr 4, 2023
@SpyrosRoum SpyrosRoum linked a pull request Apr 4, 2023 that will close this issue
@nhairs
Copy link

nhairs commented Mar 24, 2024

I have forked this project and fixed this issue see: nhairs/python-json-logger#4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants