Skip to content

Commit 70b7f88

Browse files
committed
Add newsfragment for #997
1 parent ca6ce8c commit 70b7f88

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

changelog.d/997.change.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``attrs.has()`` is now a ``TypeGuard`` for ``AttrsInstance``.
2+
That means that type checkers know a class is an instance of an ``attrs`` class if you check it using ``attrs.has()`` (or ``attr.has()``) first.

tests/typing_example.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ def accessing_from_attrs() -> None:
418418
attrs.cmp_using
419419

420420

421-
def has_typeguard() -> None:
422-
foo = object
423-
if attrs.has(foo):
424-
foo.__attrs_attrs__
421+
foo = object
422+
if attrs.has(foo) or attr.has(foo):
423+
foo.__attrs_attrs__

0 commit comments

Comments
 (0)