Skip to content

Commit 878b65e

Browse files
committed
fix: instance protocol classvars
1 parent 2ffb004 commit 878b65e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fgpyo/util/inspect.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import types as python_types
33
import typing
44
from typing import Any
5+
from typing import ClassVar
56
from typing import Dict
67
from typing import FrozenSet
78
from typing import Iterable
@@ -71,16 +72,18 @@ def get_attr_fields_dict(cls: type) -> Dict[str, dataclasses.Field]: # type: ig
7172
from _typeshed import DataclassInstance
7273
else:
7374

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

7779

7880
if TYPE_CHECKING and _use_attr: # pragma: no cover
7981
from attr import AttrsInstance
8082
else:
8183

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

8588

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

0 commit comments

Comments
 (0)