Skip to content

Commit e3a79d0

Browse files
srittauJelleZijlstra
authored andcommitted
Remove third_party/3/enum.py (#2563)
All Python 3 versions supported by typeshed (3.4+) have enum as part of the standard library. Make the third-party Python 2 version consistent with the Python 3 version.
1 parent 07bc1c9 commit e3a79d0

File tree

4 files changed

+32
-68
lines changed

4 files changed

+32
-68
lines changed

stdlib/3/enum.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# NB: third_party/3/enum.pyi and stdlib/3.4/enum.pyi must remain consistent!
1+
# NB: third_party/2/enum.pyi and stdlib/3.4/enum.pyi must remain consistent!
22
import sys
33
from typing import Any, Iterator, List, Mapping, Type, TypeVar, Union
44
from abc import ABCMeta

tests/check_consistent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{'stdlib/2and3/pyexpat/errors.pyi', 'stdlib/2and3/xml/parsers/expat/errors.pyi'},
1515
{'stdlib/2and3/pyexpat/model.pyi', 'stdlib/2and3/xml/parsers/expat/model.pyi'},
1616
{'stdlib/3/ntpath.pyi', 'stdlib/3/posixpath.pyi', 'stdlib/3/macpath.pyi', 'stdlib/3/posixpath.pyi'},
17-
{'stdlib/3/enum.pyi', 'third_party/3/enum.pyi'},
17+
{'stdlib/3/enum.pyi', 'third_party/2/enum.pyi'},
1818
{'stdlib/2/os/path.pyi', 'stdlib/3/os/path.pyi'},
1919
{'stdlib/3/unittest/mock.pyi', 'third_party/2and3/mock.pyi'},
2020
{'stdlib/3/concurrent/__init__.pyi', 'third_party/2/concurrent/__init__.pyi'},

third_party/2/enum.pyi

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized, Reversible, Container, Mapping
1+
# NB: third_party/2/enum.pyi and stdlib/3.4/enum.pyi must remain consistent!
2+
import sys
3+
from typing import Any, Iterator, List, Mapping, Type, TypeVar, Union
24
from abc import ABCMeta
35

46
_T = TypeVar('_T')
@@ -34,3 +36,30 @@ class IntEnum(int, Enum):
3436
value = ... # type: int
3537

3638
def unique(enumeration: _S) -> _S: ...
39+
40+
if sys.version_info >= (3, 6):
41+
_auto_null = ... # type: Any
42+
43+
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
44+
class auto(IntFlag):
45+
value = ... # type: Any
46+
47+
class Flag(Enum):
48+
def __contains__(self: _T, other: _T) -> bool: ...
49+
def __repr__(self) -> str: ...
50+
def __str__(self) -> str: ...
51+
def __bool__(self) -> bool: ...
52+
def __or__(self: _T, other: _T) -> _T: ...
53+
def __and__(self: _T, other: _T) -> _T: ...
54+
def __xor__(self: _T, other: _T) -> _T: ...
55+
def __invert__(self: _T) -> _T: ...
56+
57+
# The `type: ignore` comment is needed because mypy considers the type
58+
# signatures of several methods defined in int and Flag to be incompatible.
59+
class IntFlag(int, Flag): # type: ignore
60+
def __or__(self: _T, other: Union[int, _T]) -> _T: ...
61+
def __and__(self: _T, other: Union[int, _T]) -> _T: ...
62+
def __xor__(self: _T, other: Union[int, _T]) -> _T: ...
63+
__ror__ = __or__
64+
__rand__ = __and__
65+
__rxor__ = __xor__

third_party/3/enum.pyi

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)