From 97be335160a201c97eb3a2b8e3cfa07ccafc8df2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 10 Nov 2017 10:23:22 -0800 Subject: [PATCH] don't import enum in Python 2 (#1724) * don't import enum in Python 2 Fixes a pytype issue from #1720. * move enums together --- stdlib/2and3/plistlib.pyi | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/stdlib/2and3/plistlib.pyi b/stdlib/2and3/plistlib.pyi index 40a3f97e6..7173ce26c 100644 --- a/stdlib/2and3/plistlib.pyi +++ b/stdlib/2and3/plistlib.pyi @@ -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 + + 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) @@ -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], *, @@ -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