Skip to content

Commit f8df8c9

Browse files
committed
Move MemberExpr to end after test fail
1 parent 7e9e587 commit f8df8c9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

mypy/semanal.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,19 +2120,17 @@ def analyze_namedtuple_assign(self, s: AssignmentStmt) -> bool:
21202120
"""Check if s defines a namedtuple."""
21212121
if isinstance(s.rvalue, CallExpr) and isinstance(s.rvalue.analyzed, NamedTupleExpr):
21222122
return True # This is a valid and analyzed named tuple definition, nothing to do here.
2123-
if len(s.lvalues) != 1:
2124-
return False
2125-
if not isinstance(s.lvalues[0], NameExpr):
2126-
if isinstance(s.lvalues[0], MemberExpr):
2127-
self.fail("NamedTuple type as an attribute is not supported", s.lvalues[0])
2128-
return False
2123+
if len(s.lvalues) != 1 or not isinstance(s.lvalues[0], (NameExpr, MemberExpr)):
21292124
return False
21302125
lvalue = s.lvalues[0]
21312126
name = lvalue.name
21322127
is_named_tuple, info = self.named_tuple_analyzer.check_namedtuple(s.rvalue, name,
21332128
self.is_func_scope())
21342129
if not is_named_tuple:
21352130
return False
2131+
if isinstance(s.lvalues[0], MemberExpr):
2132+
self.fail("NamedTuple type as an attribute is not supported", s.lvalues[0])
2133+
return False
21362134
# Yes, it's a valid namedtuple, but defer if it is not ready.
21372135
if not info:
21382136
self.mark_incomplete(name, lvalue, becomes_typeinfo=True)

0 commit comments

Comments
 (0)