diff --git a/changelog.d/1141.change.md b/changelog.d/1141.change.md new file mode 100644 index 00000000..8112504c --- /dev/null +++ b/changelog.d/1141.change.md @@ -0,0 +1 @@ +The type annotation for `attrs.resolve_types()` is now correct. diff --git a/src/attr/__init__.pyi b/src/attr/__init__.pyi index ced5a3fd..51d1af3a 100644 --- a/src/attr/__init__.pyi +++ b/src/attr/__init__.pyi @@ -69,8 +69,7 @@ _ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]] class AttrsInstance(AttrsInstance_, Protocol): pass -_A = TypeVar("_A", bound=AttrsInstance) -# _make -- +_A = TypeVar("_A", bound=type[AttrsInstance]) class _Nothing(enum.Enum): NOTHING = enum.auto() diff --git a/tests/typing_example.py b/tests/typing_example.py index 5f5f79ab..9ffb92b4 100644 --- a/tests/typing_example.py +++ b/tests/typing_example.py @@ -468,3 +468,8 @@ if attrs.has(foo) or attr.has(foo): @attrs.define(unsafe_hash=True) class Hashable: pass + + +def test(cls: type) -> None: + if attr.has(cls): + attr.resolve_types(cls)