Add Flag, IntFlag and auto to enum stubs

Fixes python/mypy#2609
This commit is contained in:
Lukasz Langa
2016-12-28 11:26:40 -08:00
parent f8717ccfc4
commit bbc7594ec7

View File

@@ -1,4 +1,9 @@
from typing import List, Any, TypeVar
# FIXME: Stub incomplete, ommissions include:
# * the metaclass
# * _sunder_ methods with their transformations
import sys
from typing import List, Any, TypeVar, Union
class Enum:
def __new__(cls, value: Any) -> None: ...
@@ -18,3 +23,28 @@ class IntEnum(int, Enum):
_T = TypeVar('_T')
def unique(enumeration: _T) -> _T: ...
if sys.version_info >= (3, 6):
_auto_null = ... # type: Any
class auto:
value = ... # type: Any
class Flag(Enum):
def __contains__(self: _T, other: _T) -> bool: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def __bool__(self) -> bool: ...
def __or__(self: _T, other: _T) -> _T: ...
def __and__(self: _T, other: _T) -> _T: ...
def __xor__(self: _T, other: _T) -> _T: ...
def __invert__(self: _T) -> _T: ...
# All `type: ignore` comments below due to IntFlag making the function signatures more permissive.
class IntFlag(int, Flag): # type: ignore
def __or__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignore
def __and__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignore
def __xor__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignore
__ror__ = __or__
__rand__ = __and__
__rxor__ = __xor__