-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
should have an option to not fire when a non-None
default argument is provided
#5958
Comments
ANN001
should have an option to not fire when default argument is providedANN001
should have an option to not fire when a non-None
default argument is provided
I suspect it was closed because Mypy infers those types as |
Ah, I see. Given that Pyright (and, I assume, Pytype and Pyre, although I haven't used them) behave(s) differently, I'd like to keep the discussion open. |
This is by far my #1 most desired feature at the moment because, without it, I don't feel comfortable forcing this rule upon my teammates. Is there any information I can provide to help reach a decision? |
@tylerlaprade Is there an issue on mypy and/or pyright discussing this difference in behavior? |
Also, in your use-case would this apply to other types than |
Ideally, it would apply to all non-
I can go take a look, but I'm not sure why it would be relevant here. It's definitely not an unintentional feature of Pyright. |
Per the discussion at python/mypy#3090 (comment) PEP-484 says the inferred type should be It'd be great to get that amended on the language standard and have some consensus around inference. It seems like that's probably a ways off but perhaps we can start a discussion about that in the relevant forum. In the meantime, this does feel reasonable to implement although I'm not sure of the best way how. |
I don't know Rust (yet), otherwise I'd be happy to attempt it myself. There are other existing type-aware rules, right? Is there anything they do that can be reused? |
This was already raised in #794 but closed for unclear reasons. It seemed to have positive support in that thread. When I do something like
in my test fixtures, I want my attention to be called to the missing type annotation on
baz
, not unnecessary warnings oncreate_bar
,create_baz
, andcreate_qux
, because Pyright is already safely assuming them to bebool
types.This could be implemented as either breaking up
ANN001
into two separate rules, or as an additional config option as mentioned in #794.I personally think the former option results in a cleaner settings file, but it would obviously be a somewhat breaking change unless the new rule was added as
ANN0011
so that people would have to opt out of it (I don't believe any such codes currently exist, though, so it would be a deviation from the norm). The best option is therefore likely to be a new config flag, although I am happy to see this implemented in any form possible!The text was updated successfully, but these errors were encountered: