Skip to content

Commit

Permalink
Add newsfragment for #997
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Aug 16, 2022
1 parent ca6ce8c commit 70b7f88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelog.d/997.change.rst
@@ -0,0 +1,2 @@
``attrs.has()`` is now a ``TypeGuard`` for ``AttrsInstance``.
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.
7 changes: 3 additions & 4 deletions tests/typing_example.py
Expand Up @@ -418,7 +418,6 @@ def accessing_from_attrs() -> None:
attrs.cmp_using


def has_typeguard() -> None:
foo = object
if attrs.has(foo):
foo.__attrs_attrs__
foo = object
if attrs.has(foo) or attr.has(foo):
foo.__attrs_attrs__

0 comments on commit 70b7f88

Please sign in to comment.