Skip to content

don't import enum in Python 2 #1724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions stdlib/2and3/plistlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ from typing import (
Type, TypeVar,
)
from typing import Dict as DictT
from enum import Enum
import sys
if sys.version_info >= (3,):
from enum import Enum

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the definition of PlistFormat below into this "if" block, so you have all Enum related code in one block?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

class PlistFormat(Enum):
FMT_XML = ... # type: PlistFormat
FMT_BINARY = ... # type: PlistFormat
FMT_XML = PlistFormat.FMT_XML
FMT_BINARY = PlistFormat.FMT_BINARY

mm = MutableMapping[str, Any]
_D = TypeVar('_D', bound=mm)
Expand All @@ -15,15 +22,9 @@ if sys.version_info >= (3,):
else:
_Path = Union[str, unicode]


if sys.version_info >= (3,):
class PlistFormat(Enum):
FMT_XML = ... # type: PlistFormat
FMT_BINARY = ... # type: PlistFormat

if sys.version_info >= (3, 4):
def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ...,
use_builtin_types: bool, dict_type: Type[_D] =...) -> _D: ...
use_builtin_types: bool, dict_type: Type[_D] = ...) -> _D: ...
def loads(data: bytes, *, fmt: Optional[PlistFormat] = ...,
use_builtin_types: bool = ..., dict_type: Type[_D] = ...) -> _D: ...
def dump(value: Mapping[str, Any], fp: IO[bytes], *,
Expand Down Expand Up @@ -54,7 +55,3 @@ if sys.version_info >= (3,):
class Data:
data = ... # type: bytes
def __init__(self, data: bytes) -> None: ...

if sys.version_info >= (3,):
FMT_XML = PlistFormat.FMT_XML
FMT_BINARY = PlistFormat.FMT_BINARY