Skip to content

Commit 3197cd7

Browse files
committed
restrict lhs defer to TypeAlias
1 parent 168e67a commit 3197cd7

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

mypy/semanal.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,9 +3294,10 @@ def should_wait_lhs(self, s: AssignmentStmt) -> bool:
32943294
# No chance, nothing has changed.
32953295
return False
32963296
if isinstance(s.type, UnboundType):
3297-
lookup = self.lookup_qualified(s.type.name, s, suppress_errors=True)
3298-
if lookup and isinstance(lookup.node, PlaceholderNode):
3299-
return True
3297+
if s.type.name == "TypeAlias":
3298+
lookup = self.lookup_qualified(s.type.name, s, suppress_errors=True)
3299+
if lookup and isinstance(lookup.node, PlaceholderNode):
3300+
return True
33003301
return False
33013302

33023303
def should_wait_rhs(self, rv: Expression) -> bool:

mypy/typeanal.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,11 +1704,7 @@ def analyze_literal_param(self, idx: int, arg: Type, ctx: Context) -> list[Type]
17041704
# Make sure the literal's class is ready
17051705
sym = self.api.lookup_fully_qualified_or_none(arg.base_type_name)
17061706
if sym is None or isinstance(sym.node, PlaceholderNode):
1707-
assert arg.base_type_name.startswith("builtins.")
1708-
if self.api.is_incomplete_namespace("builtins"):
1709-
self.api.record_incomplete_ref()
1710-
else:
1711-
self.fail(f'Name "{arg.base_type_name}" is not defined', arg)
1707+
self.api.record_incomplete_ref()
17121708
return [AnyType(TypeOfAny.special_form)]
17131709

17141710
# Remap bytes and unicode into the appropriate type for the correct Python version

0 commit comments

Comments
 (0)