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

ANN001 is fired when argument already set (mypy not complain in such case). #794

Closed
actionless opened this issue Nov 17, 2022 · 4 comments
Closed
Labels
configuration Related to settings and configuration

Comments

@actionless
Copy link

def function(param=False) -> int:
    if param:
        return 1
    return 0
$ ruff test_ruff.py
Found 1 error(s).
test_ruff.py:1:14: ANN001 Missing type annotation for function argument `param`

$ mypy test_ruff.py
Success: no issues found in 1 source file
@actionless actionless changed the title ANN001 is fired when parameter already set (mypy not complain in such case). ANN001 is fired when argument already set (mypy not complain in such case). Nov 17, 2022
@edgarrmondragon
Copy link
Contributor

FWIW mypy does catch the missing annotation in strict mode:

$ mypy checkANN001.py --strict
checkANN001.py:1: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
Found 1 error in 1 file (checked 1 source file)

@actionless
Copy link
Author

thanks for clarifying

i wonder, if it would make sense having such option as a separate check? (in a similar way how self or cls annotation checks were extracted out)

@charliermarsh
Copy link
Member

It could make sense to turn this into a configuration setting, like allow_star_arg_any and mypy_init_return.

@charliermarsh charliermarsh added the configuration Related to settings and configuration label Nov 17, 2022
@actionless
Copy link
Author

closing because it unlikely to be implemented in mypy:
https://stackoverflow.com/a/64500210/1850190

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

No branches or pull requests

3 participants