Skip to content

Commit

Permalink
Fix type annotation for resolve_types() (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jun 4, 2023
1 parent 747b9de commit ecdb117
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/1141.change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The type annotation for `attrs.resolve_types()` is now correct.
3 changes: 1 addition & 2 deletions src/attr/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions tests/typing_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,8 @@ def accessing_from_attrs() -> None:
@attrs.define(unsafe_hash=True)
class Hashable:
pass


def test(cls: type) -> None:
if attr.has(cls):
attr.resolve_types(cls)

0 comments on commit ecdb117

Please sign in to comment.