File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -4505,7 +4505,9 @@ class C:
4505
4505
"""
4506
4506
# TODO: Forward reference to name imported in class body is not
4507
4507
# caught.
4508
- assert self .statement # we are at class scope
4508
+ if self .statement is None :
4509
+ # Assume it's fine -- don't have enough context to check
4510
+ return True
4509
4511
return (node is None
4510
4512
or self .is_textually_before_statement (node )
4511
4513
or not self .is_defined_in_current_module (node .fullname )
Original file line number Diff line number Diff line change @@ -1734,3 +1734,18 @@ class C:
1734
1734
# E: Unsupported converter, only named functions and types are currently supported
1735
1735
)
1736
1736
[builtins fixtures/dict.pyi]
1737
+
1738
+ [case testAttrsNestedClass]
1739
+ from typing import List
1740
+ import attr
1741
+
1742
+ @attr.s
1743
+ class C:
1744
+ @attr.s
1745
+ class D:
1746
+ pass
1747
+ x = attr.ib(type=List[D])
1748
+
1749
+ c = C(x=[C.D()])
1750
+ reveal_type(c.x) # N: Revealed type is "builtins.list[__main__.C.D]"
1751
+ [builtins fixtures/list.pyi]
You can’t perform that action at this time.
0 commit comments