-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New semantic analyzer: Support builtin typing aliases #6358
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
Changes from 22 commits
ffd8297
b8fe2be
30e4a1f
c37285f
835fe49
94b2f30
12960dc
358b314
75ccdf1
f63df1b
78aa606
6ebc431
9a38809
273d43f
bfb6a3c
f10744d
cf42267
0ff8ee3
ef106ca
e43d946
19a4352
9d4bbdf
f485a97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,6 +285,12 @@ def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Opt | |
" in a variable annotation", t) | ||
return AnyType(TypeOfAny.from_error) | ||
elif fullname == 'typing.Tuple': | ||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more. What happens if we don't use the correct fixture that defined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed this to report a reasonable error, and added a test. |
||
self.api.record_incomplete_ref() | ||
return AnyType(TypeOfAny.special_form) | ||
if len(t.args) == 0 and not t.empty_tuple_index: | ||
# Bare 'Tuple' is same as 'tuple' | ||
if self.options.disallow_any_generics and not self.is_typeshed_stub: | ||
|
@@ -350,7 +356,8 @@ def analyze_type_with_type_info(self, info: TypeInfo, args: List[Type], ctx: Con | |
# Instance with an invalid number of type arguments. | ||
instance = Instance(info, self.anal_array(args), ctx.line, ctx.column) | ||
# Check type argument count. | ||
if len(instance.args) != len(info.type_vars): | ||
# TODO: remove this from here and replace with a proper separate pass. | ||
if len(instance.args) != len(info.type_vars) and not self.defining_alias: | ||
fix_instance(instance, self.fail) | ||
if not args and self.options.disallow_any_generics and not self.defining_alias: | ||
# We report/patch invalid built-in instances already during second pass. | ||
|
Uh oh!
There was an error while loading. Please reload this page.