massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / enum.pyi
1 import sys
2 import types
3 from abc import ABCMeta
4 from builtins import property as _builtins_property
5 from typing import Any, Iterator, Type, TypeVar
6
7 _T = TypeVar("_T")
8 _S = TypeVar("_S", bound=Type[Enum])
9
10 # Note: EnumMeta actually subclasses type directly, not ABCMeta.
11 # This is a temporary workaround to allow multiple creation of enums with builtins
12 # such as str as mixins, which due to the handling of ABCs of builtin types, cause
13 # spurious inconsistent metaclass structure. See #1595.
14 # Structurally: Iterable[T], Reversible[T], Container[T] where T is the enum itself
15 class EnumMeta(ABCMeta):
16     def __iter__(self: Type[_T]) -> Iterator[_T]: ...
17     def __reversed__(self: Type[_T]) -> Iterator[_T]: ...
18     def __contains__(self: Type[Any], member: object) -> bool: ...
19     def __getitem__(self: Type[_T], name: str) -> _T: ...
20     @_builtins_property
21     def __members__(self: Type[_T]) -> types.MappingProxyType[str, _T]: ...
22     def __len__(self) -> int: ...
23     _member_names_: list[str]  # undocumented
24     _member_map_: dict[str, Enum]  # undocumented
25     _value2member_map_: dict[Any, Enum]  # undocumented
26
27 class Enum(metaclass=EnumMeta):
28     name: str
29     value: Any
30     _name_: str
31     _value_: Any
32     if sys.version_info >= (3, 7):
33         _ignore_: str | list[str]
34     _order_: str
35     __order__: str
36     @classmethod
37     def _missing_(cls, value: object) -> Any: ...
38     @staticmethod
39     def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any: ...
40     def __new__(cls: Type[_T], value: object) -> _T: ...
41     def __repr__(self) -> str: ...
42     def __str__(self) -> str: ...
43     def __dir__(self) -> list[str]: ...
44     def __format__(self, format_spec: str) -> str: ...
45     def __hash__(self) -> Any: ...
46     def __reduce_ex__(self, proto: object) -> Any: ...
47
48 class IntEnum(int, Enum):
49     value: int
50     def __new__(cls: Type[_T], value: int | _T) -> _T: ...
51
52 def unique(enumeration: _S) -> _S: ...
53
54 _auto_null: Any
55
56 # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
57 class auto(IntFlag):
58     value: Any
59     def __new__(cls: Type[_T]) -> _T: ...
60
61 class Flag(Enum):
62     name: str | None  # type: ignore
63     value: int
64     def __contains__(self: _T, other: _T) -> bool: ...
65     def __repr__(self) -> str: ...
66     def __str__(self) -> str: ...
67     def __bool__(self) -> bool: ...
68     def __or__(self: _T, other: _T) -> _T: ...
69     def __and__(self: _T, other: _T) -> _T: ...
70     def __xor__(self: _T, other: _T) -> _T: ...
71     def __invert__(self: _T) -> _T: ...
72
73 class IntFlag(int, Flag):
74     def __new__(cls: Type[_T], value: int | _T) -> _T: ...
75     def __or__(self: _T, other: int | _T) -> _T: ...
76     def __and__(self: _T, other: int | _T) -> _T: ...
77     def __xor__(self: _T, other: int | _T) -> _T: ...
78     def __ror__(self: _T, n: int | _T) -> _T: ...
79     def __rand__(self: _T, n: int | _T) -> _T: ...
80     def __rxor__(self: _T, n: int | _T) -> _T: ...
81
82 if sys.version_info >= (3, 11):
83     class StrEnum(str, Enum):
84         def __new__(cls: Type[_T], value: int | _T) -> _T: ...
85     class FlagBoundary(StrEnum):
86         STRICT: str
87         CONFORM: str
88         EJECT: str
89         KEEP: str
90     STRICT = FlagBoundary.STRICT
91     CONFORM = FlagBoundary.CONFORM
92     EJECT = FlagBoundary.EJECT
93     KEEP = FlagBoundary.KEEP
94     class property(_builtins_property): ...
95     def global_enum(cls: _S) -> _S: ...
96     def global_enum_repr(self: Enum) -> str: ...
97     def global_flag_repr(self: Flag) -> str: ...