##// END OF EJS Templates
typing: consolidate "if not globals():" trick...
Yuya Nishihara -
r44162:47b8ca03 default draft
parent child Browse files
Show More
@@ -27,7 +27,7 b' from .utils import ('
27 27 stringutil,
28 28 )
29 29
30 if not globals():
30 if pycompat.TYPE_CHECKING:
31 31 from typing import (
32 32 Any,
33 33 Callable,
@@ -61,7 +61,7 b' from .utils import ('
61 61 stringutil,
62 62 )
63 63
64 if not globals():
64 if pycompat.TYPE_CHECKING:
65 65 from typing import (
66 66 Any,
67 67 Dict,
@@ -20,14 +20,11 b' from . import ('
20 20
21 21 from .pure import charencode as charencodepure
22 22
23 _TYPE_CHECKING = False
24
25 if not globals(): # hide this from non-pytype users
23 if pycompat.TYPE_CHECKING:
26 24 from typing import (
27 25 Any,
28 26 Callable,
29 27 List,
30 TYPE_CHECKING as _TYPE_CHECKING,
31 28 Text,
32 29 Type,
33 30 TypeVar,
@@ -124,7 +121,7 b' class localstr(bytes):'
124 121 s._utf8 = u
125 122 return s
126 123
127 if _TYPE_CHECKING:
124 if pycompat.TYPE_CHECKING:
128 125 # pseudo implementation to help pytype see localstr() constructor
129 126 def __init__(self, u, l):
130 127 # type: (bytes, bytes) -> None
@@ -42,7 +42,7 b' from .utils import ('
42 42 )
43 43
44 44
45 if not globals():
45 if pycompat.TYPE_CHECKING:
46 46 from typing import (
47 47 Any,
48 48 Tuple,
@@ -36,7 +36,7 b' from .utils import ('
36 36 stringutil,
37 37 )
38 38
39 if not globals(): # hide this from non-pytype users
39 if pycompat.TYPE_CHECKING:
40 40 from typing import Any, List, Tuple, Union
41 41
42 42 # keep pyflakes happy
@@ -20,6 +20,12 b' import tempfile'
20 20
21 21 ispy3 = sys.version_info[0] >= 3
22 22 ispypy = '__pypy__' in sys.builtin_module_names
23 TYPE_CHECKING = False
24
25 if not globals(): # hide this from non-pytype users
26 import typing
27
28 TYPE_CHECKING = typing.TYPE_CHECKING
23 29
24 30 if not ispy3:
25 31 import cookielib
@@ -23,11 +23,12 b' from .i18n import _'
23 23
24 24 from . import (
25 25 error,
26 pycompat,
26 27 util,
27 28 )
28 29 from .utils import cborutil
29 30
30 if not globals():
31 if pycompat.TYPE_CHECKING:
31 32 from typing import (
32 33 Any,
33 34 Dict,
General Comments 0
You need to be logged in to leave comments. Login now