Skip to content

Commit ecdb117

Browse files
authored
Fix type annotation for resolve_types() (#1141)
1 parent 747b9de commit ecdb117

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

changelog.d/1141.change.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The type annotation for `attrs.resolve_types()` is now correct.

src/attr/__init__.pyi

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ _ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]]
6969
class AttrsInstance(AttrsInstance_, Protocol):
7070
pass
7171

72-
_A = TypeVar("_A", bound=AttrsInstance)
73-
# _make --
72+
_A = TypeVar("_A", bound=type[AttrsInstance])
7473

7574
class _Nothing(enum.Enum):
7675
NOTHING = enum.auto()

tests/typing_example.py

+5
Original file line numberDiff line numberDiff line change
@@ -468,3 +468,8 @@ def accessing_from_attrs() -> None:
468468
@attrs.define(unsafe_hash=True)
469469
class Hashable:
470470
pass
471+
472+
473+
def test(cls: type) -> None:
474+
if attr.has(cls):
475+
attr.resolve_types(cls)

0 commit comments

Comments
 (0)