-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
New semantic analyzer: Support builtin typing aliases #6358
New semantic analyzer: Support builtin typing aliases #6358
Conversation
Supporting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This moves us very close to being able to support full builtins stubs! Looks good, just left a few minor comments. Feel free to merge after you've addressed them.
# Tuple is special because it is involved in builtin import cycle | ||
# and may be not ready when used. | ||
sym = self.api.lookup_fully_qualified_or_none('builtins.tuple') | ||
if not sym or isinstance(sym.node, PlaceholderNode): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we don't use the correct fixture that defined tuple
? Will this still generate a reasonable error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this to report a reasonable error, and added a test.
Fixes #6297
This adds support for real typeshed stubs that define dummy aliases like
typing.List
,typing.Dict
, etc. This also fixes couple related issues, so that builtin SCC is almost clean (the two remaining errors are #6295 and #6357).Most notably, this PR introduces some re-ordering of targets in builtin SCC, removing this reordering requires some non-trivial work (namely #6356, #6355, and deferring targets from
named_type()
).