-
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
Unsafe fix for ANN2XX
is too unsafe
#8879
Labels
bug
Something isn't working
Comments
Thing = dict
def do_thing(thing: Thing | None):
if not thing:
return None
return {"foo": 1}
I don't get a suggested fix for this example. Could you provide more reproduction details? |
I can reproduce this with preview enabled -- I think it's just a bug. |
Huh, I can reproduce this in the playground but not locally. |
Oh, you need to have the target Python version set to >= 3.10. Okay. I'm on it. |
charliermarsh
added a commit
that referenced
this issue
Nov 28, 2023
## Summary Given `Union[Dict, None]` (in our internal representation), we were filtering out `Dict` since we treat it as un-representable (i.e., we can't convert it to an expression), returning just `None` as the type annotation. We should require that all members of the union are representable. Closes #8879.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The (unsafe) autofix adds
-> None
as the return type. I know this is under "unsafe" fixes, but this should be easy enough to avoid. https://github.com/JelleZijlstra/autotyping handles this case, so maybe that logic can be reused.The text was updated successfully, but these errors were encountered: