mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-10 18:36:31 +08:00
stdlib: add __slots__ (#14611)
This commit is contained in:
@@ -170,6 +170,37 @@ class _DefaultFactory(Protocol[_T_co]):
|
||||
def __call__(self) -> _T_co: ...
|
||||
|
||||
class Field(Generic[_T]):
|
||||
if sys.version_info >= (3, 14):
|
||||
__slots__ = (
|
||||
"name",
|
||||
"type",
|
||||
"default",
|
||||
"default_factory",
|
||||
"repr",
|
||||
"hash",
|
||||
"init",
|
||||
"compare",
|
||||
"metadata",
|
||||
"kw_only",
|
||||
"doc",
|
||||
"_field_type",
|
||||
)
|
||||
elif sys.version_info >= (3, 10):
|
||||
__slots__ = (
|
||||
"name",
|
||||
"type",
|
||||
"default",
|
||||
"default_factory",
|
||||
"repr",
|
||||
"hash",
|
||||
"init",
|
||||
"compare",
|
||||
"metadata",
|
||||
"kw_only",
|
||||
"_field_type",
|
||||
)
|
||||
else:
|
||||
__slots__ = ("name", "type", "default", "default_factory", "repr", "hash", "init", "compare", "metadata", "_field_type")
|
||||
name: str
|
||||
type: Type[_T] | str | Any
|
||||
default: _T | Literal[_MISSING_TYPE.MISSING]
|
||||
@@ -355,6 +386,7 @@ def is_dataclass(obj: object) -> TypeIs[DataclassInstance | type[DataclassInstan
|
||||
class FrozenInstanceError(AttributeError): ...
|
||||
|
||||
class InitVar(Generic[_T]):
|
||||
__slots__ = ("type",)
|
||||
type: Type[_T]
|
||||
def __init__(self, type: Type[_T]) -> None: ...
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user