@@ -1836,7 +1836,6 @@ def check_assignment(self, lvalue: Lvalue, rvalue: Expression, infer_lvalue_type
1836
1836
infer_lvalue_type )
1837
1837
else :
1838
1838
lvalue_type , index_lvalue , inferred = self .check_lvalue (lvalue )
1839
-
1840
1839
# If we're assigning to __getattr__ or similar methods, check that the signature is
1841
1840
# valid.
1842
1841
if isinstance (lvalue , NameExpr ) and lvalue .node :
@@ -1853,7 +1852,9 @@ def check_assignment(self, lvalue: Lvalue, rvalue: Expression, infer_lvalue_type
1853
1852
else :
1854
1853
self .check_getattr_method (signature , lvalue , name )
1855
1854
1856
- if isinstance (lvalue , RefExpr ):
1855
+ # Defer PartialType's super type checking.
1856
+ if (isinstance (lvalue , RefExpr ) and
1857
+ not (isinstance (lvalue_type , PartialType ) and lvalue_type .type is None )):
1857
1858
if self .check_compatibility_all_supers (lvalue , lvalue_type , rvalue ):
1858
1859
# We hit an error on this line; don't check for any others
1859
1860
return
@@ -1883,6 +1884,11 @@ def check_assignment(self, lvalue: Lvalue, rvalue: Expression, infer_lvalue_type
1883
1884
# Try to infer a partial type. No need to check the return value, as
1884
1885
# an error will be reported elsewhere.
1885
1886
self .infer_partial_type (lvalue_type .var , lvalue , rvalue_type )
1887
+ # Handle None PartialType's super type checking here, after it's resolved.
1888
+ if (isinstance (lvalue , RefExpr ) and
1889
+ self .check_compatibility_all_supers (lvalue , lvalue_type , rvalue )):
1890
+ # We hit an error on this line; don't check for any others
1891
+ return
1886
1892
elif (is_literal_none (rvalue ) and
1887
1893
isinstance (lvalue , NameExpr ) and
1888
1894
isinstance (lvalue .node , Var ) and
0 commit comments