-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
mypy and pylint disagree about uselessness of return statements #6530
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
Comments
I think both tools are right according to pep8 : If you don't want to return anything use |
To add to Pierre's comment, there is also an instructive docstring relating to this: |
Closing as answered. |
A better answer is "use Even though for the example above using from typing import overload, Union, Literal
@overload
def fetch_data(parse: Literal[True]) -> int:
...
@overload
def fetch_data(parse: Literal[False]) -> None:
...
@overload
def fetch_data(parse: bool) -> Union[int, None]:
...
def fetch_data(parse: bool) -> Union[int, None]: # type: ignore[return]
print(parse) |
Bug description
Configuration
No response
Command used
Pylint output
Expected behavior
No error message, because without
return None
mypy complains:And mypy swears that they are right, see for example python/mypy#3974
(By the way, the signature from exit was copied from https://mypy.readthedocs.io/en/stable/protocols.html#contextmanager-t)
Pylint version
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: