Show More
@@ -13,47 +13,50 b' from .node import (' | |||||
13 | hex, |
|
13 | hex, | |
14 | nullrev, |
|
14 | nullrev, | |
15 | ) |
|
15 | ) | |
|
16 | ||||
|
17 | from typing import ( | |||
|
18 | Any, | |||
|
19 | Callable, | |||
|
20 | Dict, | |||
|
21 | Iterable, | |||
|
22 | List, | |||
|
23 | Optional, | |||
|
24 | Set, | |||
|
25 | TYPE_CHECKING, | |||
|
26 | Tuple, | |||
|
27 | Union, | |||
|
28 | ) | |||
|
29 | ||||
16 | from . import ( |
|
30 | from . import ( | |
17 | encoding, |
|
31 | encoding, | |
18 | error, |
|
32 | error, | |
19 | obsolete, |
|
33 | obsolete, | |
20 | pycompat, |
|
|||
21 | scmutil, |
|
34 | scmutil, | |
22 | util, |
|
35 | util, | |
23 | ) |
|
36 | ) | |
|
37 | ||||
24 | from .utils import ( |
|
38 | from .utils import ( | |
25 | repoviewutil, |
|
39 | repoviewutil, | |
26 | stringutil, |
|
40 | stringutil, | |
27 | ) |
|
41 | ) | |
28 |
|
42 | |||
29 | if pycompat.TYPE_CHECKING: |
|
43 | # keeps pyflakes happy | |
30 | from typing import ( |
|
44 | assert [ | |
31 |
|
|
45 | Any, | |
32 |
|
|
46 | Callable, | |
33 |
|
|
47 | Dict, | |
34 |
|
|
48 | Iterable, | |
35 |
|
|
49 | List, | |
36 |
|
|
50 | Optional, | |
37 |
|
|
51 | Set, | |
38 |
|
|
52 | Tuple, | |
39 |
|
|
53 | Union, | |
40 | ) |
|
54 | ] | |
|
55 | ||||
|
56 | if TYPE_CHECKING: | |||
41 | from . import localrepo |
|
57 | from . import localrepo | |
42 |
|
58 | |||
43 |
assert |
|
59 | assert [localrepo] | |
44 | ( |
|
|||
45 | Any, |
|
|||
46 | Callable, |
|
|||
47 | Dict, |
|
|||
48 | Iterable, |
|
|||
49 | List, |
|
|||
50 | Optional, |
|
|||
51 | Set, |
|
|||
52 | Tuple, |
|
|||
53 | Union, |
|
|||
54 | localrepo, |
|
|||
55 | ) |
|
|||
56 | ) |
|
|||
57 |
|
60 | |||
58 | subsettable = repoviewutil.subsettable |
|
61 | subsettable = repoviewutil.subsettable | |
59 |
|
62 |
@@ -18,6 +18,7 b' from typing import (' | |||||
18 | Dict, |
|
18 | Dict, | |
19 | Iterable, |
|
19 | Iterable, | |
20 | Optional, |
|
20 | Optional, | |
|
21 | TYPE_CHECKING, | |||
21 | cast, |
|
22 | cast, | |
22 | ) |
|
23 | ) | |
23 |
|
24 | |||
@@ -71,7 +72,7 b' from .revlogutils import (' | |||||
71 | constants as revlog_constants, |
|
72 | constants as revlog_constants, | |
72 | ) |
|
73 | ) | |
73 |
|
74 | |||
74 |
if |
|
75 | if TYPE_CHECKING: | |
75 | from . import ( |
|
76 | from . import ( | |
76 | ui as uimod, |
|
77 | ui as uimod, | |
77 | ) |
|
78 | ) |
@@ -9,8 +9,19 b'' | |||||
9 | import locale |
|
9 | import locale | |
10 | import os |
|
10 | import os | |
11 | import re |
|
11 | import re | |
|
12 | import typing | |||
12 | import unicodedata |
|
13 | import unicodedata | |
13 |
|
14 | |||
|
15 | from typing import ( | |||
|
16 | Any, | |||
|
17 | Callable, | |||
|
18 | List, | |||
|
19 | Text, | |||
|
20 | Type, | |||
|
21 | TypeVar, | |||
|
22 | Union, | |||
|
23 | ) | |||
|
24 | ||||
14 | from . import ( |
|
25 | from . import ( | |
15 | error, |
|
26 | error, | |
16 | policy, |
|
27 | policy, | |
@@ -19,22 +30,11 b' from . import (' | |||||
19 |
|
30 | |||
20 | from .pure import charencode as charencodepure |
|
31 | from .pure import charencode as charencodepure | |
21 |
|
32 | |||
22 | if pycompat.TYPE_CHECKING: |
|
33 | # keep pyflakes happy | |
23 | from typing import ( |
|
34 | for t in (Any, Callable, List, Text, Type, Union): | |
24 | Any, |
|
35 | assert t | |
25 | Callable, |
|
|||
26 | List, |
|
|||
27 | Text, |
|
|||
28 | Type, |
|
|||
29 | TypeVar, |
|
|||
30 | Union, |
|
|||
31 | ) |
|
|||
32 |
|
36 | |||
33 | # keep pyflakes happy |
|
37 | _Tlocalstr = TypeVar('_Tlocalstr', bound='localstr') | |
34 | for t in (Any, Callable, List, Text, Type, Union): |
|
|||
35 | assert t |
|
|||
36 |
|
||||
37 | _Tlocalstr = TypeVar('_Tlocalstr', bound='localstr') |
|
|||
38 |
|
38 | |||
39 | charencode = policy.importmod('charencode') |
|
39 | charencode = policy.importmod('charencode') | |
40 |
|
40 | |||
@@ -131,7 +131,7 b' class localstr(bytes):' | |||||
131 | s._utf8 = u |
|
131 | s._utf8 = u | |
132 | return s |
|
132 | return s | |
133 |
|
133 | |||
134 |
if |
|
134 | if typing.TYPE_CHECKING: | |
135 | # pseudo implementation to help pytype see localstr() constructor |
|
135 | # pseudo implementation to help pytype see localstr() constructor | |
136 | def __init__(self, u, l): |
|
136 | def __init__(self, u, l): | |
137 | # type: (bytes, bytes) -> None |
|
137 | # type: (bytes, bytes) -> None |
@@ -14,19 +14,30 b' imports.' | |||||
14 |
|
14 | |||
15 | import difflib |
|
15 | import difflib | |
16 |
|
16 | |||
|
17 | from typing import ( | |||
|
18 | Any, | |||
|
19 | AnyStr, | |||
|
20 | Iterable, | |||
|
21 | List, | |||
|
22 | Optional, | |||
|
23 | Sequence, | |||
|
24 | Union, | |||
|
25 | ) | |||
|
26 | ||||
17 | # Do not import anything but pycompat here, please |
|
27 | # Do not import anything but pycompat here, please | |
18 | from . import pycompat |
|
28 | from . import pycompat | |
19 |
|
29 | |||
20 | if pycompat.TYPE_CHECKING: |
|
30 | ||
21 | from typing import ( |
|
31 | # keeps pyflakes happy | |
22 | Any, |
|
32 | assert [ | |
23 |
|
|
33 | Any, | |
24 | Iterable, |
|
34 | AnyStr, | |
25 | List, |
|
35 | Iterable, | |
26 | Optional, |
|
36 | List, | |
27 | Sequence, |
|
37 | Optional, | |
28 | Union, |
|
38 | Sequence, | |
29 | ) |
|
39 | Union, | |
|
40 | ] | |||
30 |
|
41 | |||
31 |
|
42 | |||
32 | def _tobytes(exc): |
|
43 | def _tobytes(exc): |
@@ -11,18 +11,22 b' import locale' | |||||
11 | import os |
|
11 | import os | |
12 | import sys |
|
12 | import sys | |
13 |
|
13 | |||
|
14 | from typing import ( | |||
|
15 | Callable, | |||
|
16 | List, | |||
|
17 | ) | |||
|
18 | ||||
14 | from .utils import resourceutil |
|
19 | from .utils import resourceutil | |
15 | from . import ( |
|
20 | from . import ( | |
16 | encoding, |
|
21 | encoding, | |
17 | pycompat, |
|
22 | pycompat, | |
18 | ) |
|
23 | ) | |
19 |
|
24 | |||
20 | if pycompat.TYPE_CHECKING: |
|
25 | # keeps pyflakes happy | |
21 | from typing import ( |
|
26 | assert [ | |
22 |
|
|
27 | Callable, | |
23 |
|
|
28 | List, | |
24 | ) |
|
29 | ] | |
25 |
|
||||
26 |
|
30 | |||
27 | # modelled after templater.templatepath: |
|
31 | # modelled after templater.templatepath: | |
28 | if getattr(sys, 'frozen', None) is not None: |
|
32 | if getattr(sys, 'frozen', None) is not None: |
@@ -10,6 +10,15 b' import itertools' | |||||
10 | import os |
|
10 | import os | |
11 | import posixpath |
|
11 | import posixpath | |
12 |
|
12 | |||
|
13 | from typing import ( | |||
|
14 | Any, | |||
|
15 | Callable, | |||
|
16 | Dict, | |||
|
17 | Optional, | |||
|
18 | Sequence, | |||
|
19 | Tuple, | |||
|
20 | ) | |||
|
21 | ||||
13 | from .i18n import _ |
|
22 | from .i18n import _ | |
14 | from .node import wdirrev |
|
23 | from .node import wdirrev | |
15 |
|
24 | |||
@@ -39,19 +48,19 b' from .utils import (' | |||||
39 | stringutil, |
|
48 | stringutil, | |
40 | ) |
|
49 | ) | |
41 |
|
50 | |||
|
51 | # keeps pyflakes happy | |||
|
52 | assert [ | |||
|
53 | Any, | |||
|
54 | Callable, | |||
|
55 | Dict, | |||
|
56 | Optional, | |||
|
57 | Sequence, | |||
|
58 | Tuple, | |||
|
59 | ] | |||
42 |
|
60 | |||
43 | if pycompat.TYPE_CHECKING: |
|
61 | # keep pyflakes happy | |
44 | from typing import ( |
|
62 | for t in (Any, Callable, Dict, Optional, Tuple): | |
45 | Any, |
|
63 | assert t | |
46 | Callable, |
|
|||
47 | Dict, |
|
|||
48 | Optional, |
|
|||
49 | Sequence, |
|
|||
50 | Tuple, |
|
|||
51 | ) |
|
|||
52 |
|
||||
53 | for t in (Any, Callable, Dict, Optional, Tuple): |
|
|||
54 | assert t |
|
|||
55 |
|
64 | |||
56 |
|
65 | |||
57 | def getlimit(opts): |
|
66 | def getlimit(opts): |
@@ -18,6 +18,13 b' import smtplib' | |||||
18 | import socket |
|
18 | import socket | |
19 | import time |
|
19 | import time | |
20 |
|
20 | |||
|
21 | from typing import ( | |||
|
22 | Any, | |||
|
23 | List, | |||
|
24 | Tuple, | |||
|
25 | Union, | |||
|
26 | ) | |||
|
27 | ||||
21 | from .i18n import _ |
|
28 | from .i18n import _ | |
22 | from .pycompat import ( |
|
29 | from .pycompat import ( | |
23 | open, |
|
30 | open, | |
@@ -35,11 +42,14 b' from .utils import (' | |||||
35 | urlutil, |
|
42 | urlutil, | |
36 | ) |
|
43 | ) | |
37 |
|
44 | |||
38 | if pycompat.TYPE_CHECKING: |
|
|||
39 | from typing import Any, List, Tuple, Union |
|
|||
40 |
|
45 | |||
41 |
|
|
46 | # keep pyflakes happy | |
42 | assert all((Any, List, Tuple, Union)) |
|
47 | assert [ | |
|
48 | Any, | |||
|
49 | List, | |||
|
50 | Tuple, | |||
|
51 | Union, | |||
|
52 | ] | |||
43 |
|
53 | |||
44 |
|
54 | |||
45 | class STARTTLS(smtplib.SMTP): |
|
55 | class STARTTLS(smtplib.SMTP): |
@@ -23,6 +23,14 b' from . import (' | |||||
23 | rustdirs = policy.importrust('dirstate', 'Dirs') |
|
23 | rustdirs = policy.importrust('dirstate', 'Dirs') | |
24 | parsers = policy.importmod('parsers') |
|
24 | parsers = policy.importmod('parsers') | |
25 |
|
25 | |||
|
26 | # keeps pyflakes happy | |||
|
27 | assert [ | |||
|
28 | Any, | |||
|
29 | Callable, | |||
|
30 | Iterator, | |||
|
31 | Optional, | |||
|
32 | ] | |||
|
33 | ||||
26 |
|
34 | |||
27 | def _lowerclean(s): |
|
35 | def _lowerclean(s): | |
28 | # type: (bytes) -> bytes |
|
36 | # type: (bytes) -> bytes |
@@ -102,6 +102,18 b' Note: old client behave as a publishing ' | |||||
102 |
|
102 | |||
103 |
|
103 | |||
104 | import struct |
|
104 | import struct | |
|
105 | import typing | |||
|
106 | ||||
|
107 | from typing import ( | |||
|
108 | Any, | |||
|
109 | Callable, | |||
|
110 | Dict, | |||
|
111 | Iterable, | |||
|
112 | List, | |||
|
113 | Optional, | |||
|
114 | Set, | |||
|
115 | Tuple, | |||
|
116 | ) | |||
105 |
|
117 | |||
106 | from .i18n import _ |
|
118 | from .i18n import _ | |
107 | from .node import ( |
|
119 | from .node import ( | |
@@ -120,23 +132,29 b' from . import (' | |||||
120 | util, |
|
132 | util, | |
121 | ) |
|
133 | ) | |
122 |
|
134 | |||
123 | if pycompat.TYPE_CHECKING: |
|
135 | # keeps pyflakes happy | |
124 | from typing import ( |
|
136 | assert [ | |
125 |
|
|
137 | Any, | |
126 |
|
|
138 | Callable, | |
127 |
|
|
139 | Dict, | |
128 |
|
|
140 | Iterable, | |
129 |
|
|
141 | List, | |
130 |
|
|
142 | Optional, | |
131 |
|
|
143 | Set, | |
132 |
|
|
144 | Tuple, | |
133 | ) |
|
145 | ] | |
|
146 | ||||
|
147 | Phaseroots = Dict[int, Set[bytes]] | |||
|
148 | ||||
|
149 | if typing.TYPE_CHECKING: | |||
134 | from . import ( |
|
150 | from . import ( | |
135 | localrepo, |
|
151 | localrepo, | |
136 | ui as uimod, |
|
152 | ui as uimod, | |
137 | ) |
|
153 | ) | |
138 |
|
154 | |||
139 | Phaseroots = Dict[int, Set[bytes]] |
|
155 | # keeps pyflakes happy | |
|
156 | assert [uimod] | |||
|
157 | ||||
140 | Phasedefaults = List[ |
|
158 | Phasedefaults = List[ | |
141 | Callable[[localrepo.localrepository, Phaseroots], Phaseroots] |
|
159 | Callable[[localrepo.localrepository, Phaseroots], Phaseroots] | |
142 | ] |
|
160 | ] |
@@ -70,13 +70,6 b' rename = os.rename' | |||||
70 | removedirs = os.removedirs |
|
70 | removedirs = os.removedirs | |
71 |
|
71 | |||
72 | if typing.TYPE_CHECKING: |
|
72 | if typing.TYPE_CHECKING: | |
73 | # Replace the various overloads that come along with aliasing stdlib methods |
|
|||
74 | # with the narrow definition that we care about in the type checking phase |
|
|||
75 | # only. This ensures that both Windows and POSIX see only the definition |
|
|||
76 | # that is actually available. |
|
|||
77 | # |
|
|||
78 | # Note that if we check pycompat.TYPE_CHECKING here, it is always False, and |
|
|||
79 | # the methods aren't replaced. |
|
|||
80 |
|
73 | |||
81 | def normpath(path: bytes) -> bytes: |
|
74 | def normpath(path: bytes) -> bytes: | |
82 | raise NotImplementedError |
|
75 | raise NotImplementedError |
@@ -3,6 +3,7 b' import errno' | |||||
3 | import fcntl |
|
3 | import fcntl | |
4 | import os |
|
4 | import os | |
5 | import sys |
|
5 | import sys | |
|
6 | import typing | |||
6 |
|
7 | |||
7 | from typing import ( |
|
8 | from typing import ( | |
8 | List, |
|
9 | List, | |
@@ -15,7 +16,7 b' from . import (' | |||||
15 | util, |
|
16 | util, | |
16 | ) |
|
17 | ) | |
17 |
|
18 | |||
18 |
if |
|
19 | if typing.TYPE_CHECKING: | |
19 | from . import ui as uimod |
|
20 | from . import ui as uimod | |
20 |
|
21 | |||
21 | # BSD 'more' escapes ANSI color sequences by default. This can be disabled by |
|
22 | # BSD 'more' escapes ANSI color sequences by default. This can be disabled by |
@@ -3,6 +3,7 b' import winreg # pytype: disable=import-' | |||||
3 |
|
3 | |||
4 | from typing import ( |
|
4 | from typing import ( | |
5 | List, |
|
5 | List, | |
|
6 | TYPE_CHECKING, | |||
6 | Tuple, |
|
7 | Tuple, | |
7 | ) |
|
8 | ) | |
8 |
|
9 | |||
@@ -13,7 +14,7 b' from . import (' | |||||
13 | win32, |
|
14 | win32, | |
14 | ) |
|
15 | ) | |
15 |
|
16 | |||
16 |
if |
|
17 | if TYPE_CHECKING: | |
17 | from . import ui as uimod |
|
18 | from . import ui as uimod | |
18 |
|
19 | |||
19 | # MS-DOS 'more' is the only pager available by default on Windows. |
|
20 | # MS-DOS 'more' is the only pager available by default on Windows. |
@@ -20,23 +20,22 b' the data.' | |||||
20 |
|
20 | |||
21 | import contextlib |
|
21 | import contextlib | |
22 |
|
22 | |||
|
23 | from typing import ( | |||
|
24 | Any, | |||
|
25 | Dict, | |||
|
26 | ) | |||
|
27 | ||||
23 | from .i18n import _ |
|
28 | from .i18n import _ | |
24 |
|
29 | |||
25 | from . import ( |
|
30 | from . import ( | |
26 | error, |
|
31 | error, | |
27 | pycompat, |
|
|||
28 | util, |
|
32 | util, | |
29 | ) |
|
33 | ) | |
30 | from .utils import cborutil |
|
34 | from .utils import cborutil | |
31 |
|
35 | |||
32 | if pycompat.TYPE_CHECKING: |
|
36 | # keeps pyflakes happy | |
33 | from typing import ( |
|
37 | for t in (Any, Dict): | |
34 | Any, |
|
38 | assert t | |
35 | Dict, |
|
|||
36 | ) |
|
|||
37 |
|
||||
38 | for t in (Any, Dict): |
|
|||
39 | assert t |
|
|||
40 |
|
39 | |||
41 |
|
40 | |||
42 | class cmdstate: |
|
41 | class cmdstate: |
@@ -9,6 +9,16 b'' | |||||
9 | import os |
|
9 | import os | |
10 | import posixpath |
|
10 | import posixpath | |
11 | import re |
|
11 | import re | |
|
12 | import typing | |||
|
13 | ||||
|
14 | from typing import ( | |||
|
15 | Any, | |||
|
16 | Dict, | |||
|
17 | List, | |||
|
18 | Optional, | |||
|
19 | Set, | |||
|
20 | Tuple, | |||
|
21 | ) | |||
12 |
|
22 | |||
13 | from .i18n import _ |
|
23 | from .i18n import _ | |
14 | from . import ( |
|
24 | from . import ( | |
@@ -17,7 +27,6 b' from . import (' | |||||
17 | filemerge, |
|
27 | filemerge, | |
18 | pathutil, |
|
28 | pathutil, | |
19 | phases, |
|
29 | phases, | |
20 | pycompat, |
|
|||
21 | util, |
|
30 | util, | |
22 | ) |
|
31 | ) | |
23 | from .utils import ( |
|
32 | from .utils import ( | |
@@ -25,17 +34,19 b' from .utils import (' | |||||
25 | urlutil, |
|
34 | urlutil, | |
26 | ) |
|
35 | ) | |
27 |
|
36 | |||
|
37 | # keeps pyflakes happy | |||
|
38 | assert [ | |||
|
39 | Any, | |||
|
40 | Dict, | |||
|
41 | List, | |||
|
42 | Optional, | |||
|
43 | Set, | |||
|
44 | Tuple, | |||
|
45 | ] | |||
|
46 | ||||
28 | nullstate = (b'', b'', b'empty') |
|
47 | nullstate = (b'', b'', b'empty') | |
29 |
|
48 | |||
30 |
if |
|
49 | if typing.TYPE_CHECKING: | |
31 | from typing import ( |
|
|||
32 | Any, |
|
|||
33 | Dict, |
|
|||
34 | List, |
|
|||
35 | Optional, |
|
|||
36 | Set, |
|
|||
37 | Tuple, |
|
|||
38 | ) |
|
|||
39 | from . import ( |
|
50 | from . import ( | |
40 | context, |
|
51 | context, | |
41 | localrepo, |
|
52 | localrepo, | |
@@ -45,7 +56,17 b' if pycompat.TYPE_CHECKING:' | |||||
45 | ui as uimod, |
|
56 | ui as uimod, | |
46 | ) |
|
57 | ) | |
47 |
|
58 | |||
48 | Substate = Dict[bytes, Tuple[bytes, bytes, bytes]] |
|
59 | # keeps pyflakes happy | |
|
60 | assert [ | |||
|
61 | context, | |||
|
62 | localrepo, | |||
|
63 | matchmod, | |||
|
64 | scmutil, | |||
|
65 | subrepo, | |||
|
66 | uimod, | |||
|
67 | ] | |||
|
68 | ||||
|
69 | Substate = Dict[bytes, Tuple[bytes, bytes, bytes]] | |||
49 |
|
70 | |||
50 |
|
71 | |||
51 | def state(ctx, ui): |
|
72 | def state(ctx, ui): |
@@ -18,6 +18,7 b' import socket' | |||||
18 | import subprocess |
|
18 | import subprocess | |
19 | import sys |
|
19 | import sys | |
20 | import traceback |
|
20 | import traceback | |
|
21 | import typing | |||
21 |
|
22 | |||
22 | from typing import ( |
|
23 | from typing import ( | |
23 | Any, |
|
24 | Any, | |
@@ -1766,7 +1767,7 b' class ui:' | |||||
1766 |
|
1767 | |||
1767 | return line |
|
1768 | return line | |
1768 |
|
1769 | |||
1769 |
if |
|
1770 | if typing.TYPE_CHECKING: | |
1770 |
|
1771 | |||
1771 | @overload |
|
1772 | @overload | |
1772 | def prompt(self, msg: bytes, default: bytes) -> bytes: |
|
1773 | def prompt(self, msg: bytes, default: bytes) -> bytes: | |
@@ -1782,7 +1783,7 b' class ui:' | |||||
1782 | """ |
|
1783 | """ | |
1783 | return self._prompt(msg, default=default) |
|
1784 | return self._prompt(msg, default=default) | |
1784 |
|
1785 | |||
1785 |
if |
|
1786 | if typing.TYPE_CHECKING: | |
1786 |
|
1787 | |||
1787 | @overload |
|
1788 | @overload | |
1788 | def _prompt( |
|
1789 | def _prompt( |
@@ -7,11 +7,15 b'' | |||||
7 |
|
7 | |||
8 | import random |
|
8 | import random | |
9 |
|
9 | |||
|
10 | from typing import ( | |||
|
11 | List, | |||
|
12 | Type, | |||
|
13 | ) | |||
|
14 | ||||
10 | from ..i18n import _ |
|
15 | from ..i18n import _ | |
11 | from .. import ( |
|
16 | from .. import ( | |
12 | error, |
|
17 | error, | |
13 | localrepo, |
|
18 | localrepo, | |
14 | pycompat, |
|
|||
15 | requirements, |
|
19 | requirements, | |
16 | revlog, |
|
20 | revlog, | |
17 | util, |
|
21 | util, | |
@@ -19,12 +23,11 b' from .. import (' | |||||
19 |
|
23 | |||
20 | from ..utils import compression |
|
24 | from ..utils import compression | |
21 |
|
25 | |||
22 | if pycompat.TYPE_CHECKING: |
|
26 | # keeps pyflakes happy | |
23 | from typing import ( |
|
27 | assert [ | |
24 |
|
|
28 | List, | |
25 |
|
|
29 | Type, | |
26 | ) |
|
30 | ] | |
27 |
|
||||
28 |
|
31 | |||
29 | # list of requirements that request a clone of all revlog if added/removed |
|
32 | # list of requirements that request a clone of all revlog if added/removed | |
30 | RECLONES_REQUIREMENTS = { |
|
33 | RECLONES_REQUIREMENTS = { |
@@ -34,6 +34,14 b' import time' | |||||
34 | import traceback |
|
34 | import traceback | |
35 | import warnings |
|
35 | import warnings | |
36 |
|
36 | |||
|
37 | from typing import ( | |||
|
38 | Iterable, | |||
|
39 | Iterator, | |||
|
40 | List, | |||
|
41 | Optional, | |||
|
42 | Tuple, | |||
|
43 | ) | |||
|
44 | ||||
37 | from .node import hex |
|
45 | from .node import hex | |
38 | from .thirdparty import attr |
|
46 | from .thirdparty import attr | |
39 | from .pycompat import ( |
|
47 | from .pycompat import ( | |
@@ -55,14 +63,14 b' from .utils import (' | |||||
55 | stringutil, |
|
63 | stringutil, | |
56 | ) |
|
64 | ) | |
57 |
|
65 | |||
58 | if pycompat.TYPE_CHECKING: |
|
66 | # keeps pyflakes happy | |
59 | from typing import ( |
|
67 | assert [ | |
60 |
|
|
68 | Iterable, | |
61 |
|
|
69 | Iterator, | |
62 |
|
|
70 | List, | |
63 |
|
|
71 | Optional, | |
64 |
|
|
72 | Tuple, | |
65 | ) |
|
73 | ] | |
66 |
|
74 | |||
67 |
|
75 | |||
68 | base85 = policy.importmod('base85') |
|
76 | base85 = policy.importmod('base85') |
@@ -10,6 +10,15 b' import calendar' | |||||
10 | import datetime |
|
10 | import datetime | |
11 | import time |
|
11 | import time | |
12 |
|
12 | |||
|
13 | from typing import ( | |||
|
14 | Callable, | |||
|
15 | Dict, | |||
|
16 | Iterable, | |||
|
17 | Optional, | |||
|
18 | Tuple, | |||
|
19 | Union, | |||
|
20 | ) | |||
|
21 | ||||
13 | from ..i18n import _ |
|
22 | from ..i18n import _ | |
14 | from .. import ( |
|
23 | from .. import ( | |
15 | encoding, |
|
24 | encoding, | |
@@ -17,17 +26,17 b' from .. import (' | |||||
17 | pycompat, |
|
26 | pycompat, | |
18 | ) |
|
27 | ) | |
19 |
|
28 | |||
20 | if pycompat.TYPE_CHECKING: |
|
29 | # keeps pyflakes happy | |
21 | from typing import ( |
|
30 | assert [ | |
22 |
|
|
31 | Callable, | |
23 |
|
|
32 | Dict, | |
24 |
|
|
33 | Iterable, | |
25 |
|
|
34 | Optional, | |
26 |
|
|
35 | Tuple, | |
27 |
|
|
36 | Union, | |
28 | ) |
|
37 | ] | |
29 |
|
38 | |||
30 |
|
|
39 | hgdate = Tuple[float, int] # (unixtime, offset) | |
31 |
|
40 | |||
32 | # used by parsedate |
|
41 | # used by parsedate | |
33 | defaultdateformats = ( |
|
42 | defaultdateformats = ( |
@@ -8,6 +8,10 b' import os' | |||||
8 | import re as remod |
|
8 | import re as remod | |
9 | import socket |
|
9 | import socket | |
10 |
|
10 | |||
|
11 | from typing import ( | |||
|
12 | Union, | |||
|
13 | ) | |||
|
14 | ||||
11 | from ..i18n import _ |
|
15 | from ..i18n import _ | |
12 | from .. import ( |
|
16 | from .. import ( | |
13 | encoding, |
|
17 | encoding, | |
@@ -24,11 +28,8 b' from ..revlogutils import (' | |||||
24 | constants as revlog_constants, |
|
28 | constants as revlog_constants, | |
25 | ) |
|
29 | ) | |
26 |
|
30 | |||
27 |
|
31 | # keeps pyflakes happy | ||
28 | if pycompat.TYPE_CHECKING: |
|
32 | assert [Union] | |
29 | from typing import ( |
|
|||
30 | Union, |
|
|||
31 | ) |
|
|||
32 |
|
33 | |||
33 | urlreq = urllibcompat.urlreq |
|
34 | urlreq = urllibcompat.urlreq | |
34 |
|
35 |
@@ -61,13 +61,7 b' testpid = win32.testpid' | |||||
61 | unlink = win32.unlink |
|
61 | unlink = win32.unlink | |
62 |
|
62 | |||
63 | if typing.TYPE_CHECKING: |
|
63 | if typing.TYPE_CHECKING: | |
64 | # Replace the various overloads that come along with aliasing stdlib methods |
|
64 | ||
65 | # with the narrow definition that we care about in the type checking phase |
|
|||
66 | # only. This ensures that both Windows and POSIX see only the definition |
|
|||
67 | # that is actually available. |
|
|||
68 | # |
|
|||
69 | # Note that if we check pycompat.TYPE_CHECKING here, it is always False, and |
|
|||
70 | # the methods aren't replaced. |
|
|||
71 | def split(p: bytes) -> Tuple[bytes, bytes]: |
|
65 | def split(p: bytes) -> Tuple[bytes, bytes]: | |
72 | raise NotImplementedError |
|
66 | raise NotImplementedError | |
73 |
|
67 |
General Comments 0
You need to be logged in to leave comments.
Login now