-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
TopologicalSorter is not Generic at runtime (but is in typeshed) #89522
Comments
Reproduction:
I opened the issue here (rather than typeshed) because we'd presumably like to support this at runtime too. Typeshed link: https://github.com/python/mypy/blob/0a830481980bfc554ded61a3eaaaecde384a21e4/mypy/typeshed/stdlib/graphlib.pyi#L6 |
The new feature is applied to Python 3.11 only |
Thanks for merging! Should typeshed be updated for <3.11 in the meantime or do you suggest |
`if TYPE_CHECKING:` is a good choice, it works fine just now. I don't see a reason for REMOVING already existing and correct annotations from typeshed. |
Another option for code using Python <3.11, that will work without the
By using a string as the annotation, we give mypy the specificity it needs, but the expression will never need to be resolved at runtime. |
Thanks for the tips! I've been using this patch in my own code in a early imported
Certainly a bit hacky, but aside from no-op on >=3.11 and satisfying mypy, it supports runtime type inspection via |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: