Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4505,7 +4505,9 @@ class C:
"""
# TODO: Forward reference to name imported in class body is not
# caught.
assert self.statement # we are at class scope
if self.statement is None:
# Assume it's fine -- don't have enough context to check
return True
return (node is None
or self.is_textually_before_statement(node)
or not self.is_defined_in_current_module(node.fullname)
Expand Down
15 changes: 15 additions & 0 deletions test-data/unit/check-attr.test
Original file line number Diff line number Diff line change
Expand Up @@ -1734,3 +1734,18 @@ class C:
# E: Unsupported converter, only named functions and types are currently supported
)
[builtins fixtures/dict.pyi]

[case testAttrsNestedClass]
from typing import List
import attr

@attr.s
class C:
@attr.s
class D:
pass
x = attr.ib(type=List[D])

c = C(x=[C.D()])
reveal_type(c.x) # N: Revealed type is "builtins.list[__main__.C.D]"
[builtins fixtures/list.pyi]