From fff7a10ae778e60a5212214051bf43f2236412ca Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Thu, 8 Oct 2020 16:09:24 -0700 Subject: [PATCH] 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. --- stdlib/2and3/pstats.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2and3/pstats.pyi b/stdlib/2and3/pstats.pyi index 68c937e27..9c74aeb9c 100644 --- a/stdlib/2and3/pstats.pyi +++ b/stdlib/2and3/pstats.pyi @@ -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