Export DataclassInstance protocol from _typeshed (#9676)

This commit is contained in:
Marc Mueller
2023-02-04 16:58:11 +01:00
committed by GitHub
parent b9270da7b0
commit 88a761ed4e
2 changed files with 20 additions and 14 deletions

View File

@@ -8,9 +8,10 @@ import mmap
import pickle
import sys
from collections.abc import Awaitable, Callable, Iterable, Set as AbstractSet
from dataclasses import Field
from os import PathLike
from types import FrameType, TracebackType
from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union
from typing import Any, AnyStr, ClassVar, Generic, Protocol, TypeVar, Union
from typing_extensions import Final, Literal, LiteralString, TypeAlias, final
_KT = TypeVar("_KT")
@@ -304,3 +305,10 @@ ProfileFunction: TypeAlias = Callable[[FrameType, str, Any], object]
# Objects suitable to be passed to sys.settrace, threading.settrace, and similar
TraceFunction: TypeAlias = Callable[[FrameType, str, Any], TraceFunction | None]
# experimental
# Might not work as expected for pyright, see
# https://github.com/python/typeshed/pull/9362
# https://github.com/microsoft/pyright/issues/4339
class DataclassInstance(Protocol):
__dataclass_fields__: ClassVar[dict[str, Field[Any]]]