mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Use lowercase type everywhere (#6853)
This commit is contained in:
@@ -3,10 +3,10 @@ import types
|
||||
from abc import ABCMeta
|
||||
from builtins import property as _builtins_property
|
||||
from collections.abc import Iterable, Iterator, Mapping
|
||||
from typing import Any, Type, TypeVar, Union, overload
|
||||
from typing import Any, TypeVar, Union, overload
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_S = TypeVar("_S", bound=Type[Enum])
|
||||
_S = TypeVar("_S", bound=type[Enum])
|
||||
|
||||
# The following all work:
|
||||
# >>> from enum import Enum
|
||||
@@ -32,7 +32,7 @@ class _EnumDict(dict[str, Any]):
|
||||
class EnumMeta(ABCMeta):
|
||||
if sys.version_info >= (3, 11):
|
||||
def __new__(
|
||||
metacls: Type[_T],
|
||||
metacls: type[_T],
|
||||
cls: str,
|
||||
bases: tuple[type, ...],
|
||||
classdict: _EnumDict,
|
||||
@@ -42,20 +42,20 @@ class EnumMeta(ABCMeta):
|
||||
**kwds: Any,
|
||||
) -> _T: ...
|
||||
elif sys.version_info >= (3, 9):
|
||||
def __new__(metacls: Type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> _T: ... # type: ignore
|
||||
def __new__(metacls: type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> _T: ... # type: ignore
|
||||
else:
|
||||
def __new__(metacls: Type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> _T: ... # type: ignore
|
||||
def __iter__(self: Type[_T]) -> Iterator[_T]: ...
|
||||
def __reversed__(self: Type[_T]) -> Iterator[_T]: ...
|
||||
def __contains__(self: Type[Any], member: object) -> bool: ...
|
||||
def __getitem__(self: Type[_T], name: str) -> _T: ...
|
||||
def __new__(metacls: type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> _T: ... # type: ignore
|
||||
def __iter__(self: type[_T]) -> Iterator[_T]: ...
|
||||
def __reversed__(self: type[_T]) -> Iterator[_T]: ...
|
||||
def __contains__(self: type[Any], member: object) -> bool: ...
|
||||
def __getitem__(self: type[_T], name: str) -> _T: ...
|
||||
@_builtins_property
|
||||
def __members__(self: Type[_T]) -> types.MappingProxyType[str, _T]: ...
|
||||
def __members__(self: type[_T]) -> types.MappingProxyType[str, _T]: ...
|
||||
def __len__(self) -> int: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
# Simple value lookup
|
||||
@overload # type: ignore[override]
|
||||
def __call__(cls: Type[_T], value: Any, names: None = ...) -> _T: ...
|
||||
def __call__(cls: type[_T], value: Any, names: None = ...) -> _T: ...
|
||||
# Functional Enum API
|
||||
@overload
|
||||
def __call__(
|
||||
@@ -68,10 +68,10 @@ class EnumMeta(ABCMeta):
|
||||
type: type | None = ...,
|
||||
start: int = ...,
|
||||
boundary: FlagBoundary | None = ...,
|
||||
) -> Type[Enum]: ...
|
||||
) -> type[Enum]: ...
|
||||
else:
|
||||
@overload # type: ignore[override]
|
||||
def __call__(cls: Type[_T], value: Any, names: None = ...) -> _T: ...
|
||||
def __call__(cls: type[_T], value: Any, names: None = ...) -> _T: ...
|
||||
@overload
|
||||
def __call__(
|
||||
cls,
|
||||
@@ -82,7 +82,7 @@ class EnumMeta(ABCMeta):
|
||||
qualname: str | None = ...,
|
||||
type: type | None = ...,
|
||||
start: int = ...,
|
||||
) -> Type[Enum]: ...
|
||||
) -> type[Enum]: ...
|
||||
_member_names_: list[str] # undocumented
|
||||
_member_map_: dict[str, Enum] # undocumented
|
||||
_value2member_map_: dict[Any, Enum] # undocumented
|
||||
@@ -112,7 +112,7 @@ class Enum(metaclass=EnumMeta):
|
||||
def _missing_(cls, value: object) -> Any: ...
|
||||
@staticmethod
|
||||
def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any: ...
|
||||
def __new__(cls: Type[_T], value: object) -> _T: ...
|
||||
def __new__(cls: type[_T], value: object) -> _T: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __str__(self) -> str: ...
|
||||
def __dir__(self) -> list[str]: ...
|
||||
@@ -128,7 +128,7 @@ class IntEnum(int, Enum):
|
||||
else:
|
||||
@types.DynamicClassAttribute
|
||||
def value(self) -> int: ...
|
||||
def __new__(cls: Type[_T], value: int | _T) -> _T: ...
|
||||
def __new__(cls: type[_T], value: int | _T) -> _T: ...
|
||||
|
||||
def unique(enumeration: _S) -> _S: ...
|
||||
|
||||
@@ -143,7 +143,7 @@ class auto(IntFlag):
|
||||
else:
|
||||
@types.DynamicClassAttribute
|
||||
def value(self) -> Any: ...
|
||||
def __new__(cls: Type[_T]) -> _T: ...
|
||||
def __new__(cls: type[_T]) -> _T: ...
|
||||
|
||||
class Flag(Enum):
|
||||
_name_: str | None # type: ignore[assignment]
|
||||
@@ -168,7 +168,7 @@ class Flag(Enum):
|
||||
def __invert__(self: _T) -> _T: ...
|
||||
|
||||
class IntFlag(int, Flag):
|
||||
def __new__(cls: Type[_T], value: int | _T) -> _T: ...
|
||||
def __new__(cls: type[_T], value: int | _T) -> _T: ...
|
||||
def __or__(self: _T, other: int | _T) -> _T: ...
|
||||
def __and__(self: _T, other: int | _T) -> _T: ...
|
||||
def __xor__(self: _T, other: int | _T) -> _T: ...
|
||||
@@ -178,7 +178,7 @@ class IntFlag(int, Flag):
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
class StrEnum(str, Enum):
|
||||
def __new__(cls: Type[_T], value: str | _T) -> _T: ...
|
||||
def __new__(cls: type[_T], value: str | _T) -> _T: ...
|
||||
_value_: str
|
||||
@property
|
||||
def value(self) -> str: ...
|
||||
@@ -192,7 +192,7 @@ if sys.version_info >= (3, 11):
|
||||
EJECT = FlagBoundary.EJECT
|
||||
KEEP = FlagBoundary.KEEP
|
||||
class property(types.DynamicClassAttribute):
|
||||
def __set_name__(self, ownerclass: Type[Enum], name: str) -> None: ...
|
||||
def __set_name__(self, ownerclass: type[Enum], name: str) -> None: ...
|
||||
name: str
|
||||
clsname: str
|
||||
def global_enum(cls: _S) -> _S: ...
|
||||
|
||||
Reference in New Issue
Block a user