-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Should unions including Any
trigger ANN401
(or some other rule)?
#5458
Comments
I think it should be included, yeah. |
Maybe we can reuse the logic that @dhruvmanila added for implicit optionals. |
If I understand correctly, do you mean to check if there's |
The latter! Does that make sense? |
It does but then |
Actually, this then brings up the question if we should look for I believe the main question would be "does this type resolve to |
Err, sorry, I may have misunderstood your question. We're just looking to understand whether the type resolves to |
Right, then I believe the following cases should also be considered although the original plugin doesn't support them.
Does this make sense? I don't think |
Yes, agreed. |
It should be simple enough to extract out the logic from |
See #5458 for detailed information I've tried to split this into commits for individual rules as much as feasible and left a bunch of TODO where i'm not sure about the rules --------- Co-authored-by: Micha Reiser <[email protected]>
See #5458 for detailed information I've tried to split this into commits for individual rules as much as feasible and left a bunch of TODO where i'm not sure about the rules --------- Co-authored-by: Micha Reiser <[email protected]>
See #5458 for detailed information I've tried to split this into commits for individual rules as much as feasible and left a bunch of TODO where i'm not sure about the rules --------- Co-authored-by: Micha Reiser <[email protected]>
## Summary Check for `Any` in other types for `ANN401`. This reuses the logic from `implicit-optional` rule to resolve the type to `Any`. Following types are supported: * `Union[Any, ...]` * `Any | ...` * `Optional[Any]` * `Annotated[<any of the above variant>, ...]` * Forward references i.e., `"Any | ..."` ## Test Plan Added test cases for various combinations. fixes: #5458
See #5458 for detailed information I've tried to split this into commits for individual rules as much as feasible and left a bunch of TODO where i'm not sure about the rules --------- Co-authored-by: Micha Reiser <[email protected]>
See #5458 for detailed information I've tried to split this into commits for individual rules as much as feasible and left a bunch of TODO where i'm not sure about the rules --------- Co-authored-by: Micha Reiser <[email protected]>
See #5458 for detailed information I've tried to split this into commits for individual rules as much as feasible and left a bunch of TODO where i'm not sure about the rules --------- Co-authored-by: Micha Reiser <[email protected]>
## Summary Check for `Any` in other types for `ANN401`. This reuses the logic from `implicit-optional` rule to resolve the type to `Any`. Following types are supported: * `Union[Any, ...]` * `Any | ...` * `Optional[Any]` * `Annotated[<any of the above variant>, ...]` * Forward references i.e., `"Any | ..."` ## Test Plan Added test cases for various combinations. fixes: #5458
gives
I wonder why that error is not also emitted for
fun_no_error
.Any | None
is at least as undefined asAny
is.Another option would be to add a new rule that says
The text was updated successfully, but these errors were encountered: