Skip to content

Commit

Permalink
fix: instance protocol classvars
Browse files Browse the repository at this point in the history
  • Loading branch information
msto committed May 6, 2024
1 parent 2ffb004 commit 878b65e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fgpyo/util/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import types as python_types
import typing
from typing import Any
from typing import ClassVar
from typing import Dict
from typing import FrozenSet
from typing import Iterable
Expand Down Expand Up @@ -71,16 +72,18 @@ def get_attr_fields_dict(cls: type) -> Dict[str, dataclasses.Field]: # type: ig
from _typeshed import DataclassInstance
else:

# https://github.com/python/typeshed/blob/727f3c4320d2af3af2f16695e24dd78e79b7c070/stdlib/_typeshed/__init__.pyi#L348
class DataclassInstance(Protocol):
__dataclasses_fields__: Dict[str, dataclasses.Field]
__dataclasses_fields__: ClassVar[Dict[str, dataclasses.Field[Any]]]


if TYPE_CHECKING and _use_attr: # pragma: no cover
from attr import AttrsInstance
else:

# https://github.com/python-attrs/attrs/blob/f7f317ae4c3790f23ae027db626593d50e8a4e88/src/attr/_typing_compat.pyi#L9
class AttrsInstance(Protocol): # type: ignore[no-redef]
__attrs_attrs__: Dict[str, Any]
__attrs_attrs__: ClassVar[Any]


def is_attr_class(cls: type) -> bool: # type: ignore[arg-type]
Expand Down

0 comments on commit 878b65e

Please sign in to comment.