Add a version guard for importing enum in pstats. (#4635)

* Add a version guard for importing enum.

I'm trying to pull the latest version of typeshed into Google, and
pytype chokes on pstats in Python 2 because the enum module was
introduced in 3.4.

* Move the enum import into the branch that defines SortKey.
This commit is contained in:
Rebecca Chen
2020-10-08 16:09:24 -07:00
committed by GitHub
parent 35f4ade96f
commit fff7a10ae7

View File

@@ -1,7 +1,6 @@
import sys
from _typeshed import AnyPath
from cProfile import Profile as _cProfile
from enum import Enum
from profile import Profile
from typing import IO, Any, Dict, Iterable, List, Optional, Text, Tuple, TypeVar, Union, overload
@@ -9,6 +8,7 @@ _Selector = Union[str, float, int]
_T = TypeVar("_T", bound=Stats)
if sys.version_info >= (3, 7):
from enum import Enum
class SortKey(str, Enum):
CALLS: str
CUMULATIVE: str