Mercurial > hg-stable
comparison mercurial/util.py @ 51302:9d3721552b6c
pytype: import typing directly
First we no longer needs the pycompat layer, second having the types imported in
all case will allow to use them more directly in type annotation, something
important to upgrade the old "type comment" to proper type annotation.
A lot a stupid assert are needed to keep pyflakes happy. We should be able to
remove most of them once the type comment have been upgraded.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 20 Dec 2023 12:51:20 +0100 |
parents | 18c8c18993f0 |
children | f15cb5111a1e |
comparison
equal
deleted
inserted
replaced
51301:58d39c7865e5 | 51302:9d3721552b6c |
---|---|
31 import stat | 31 import stat |
32 import sys | 32 import sys |
33 import time | 33 import time |
34 import traceback | 34 import traceback |
35 import warnings | 35 import warnings |
36 | |
37 from typing import ( | |
38 Iterable, | |
39 Iterator, | |
40 List, | |
41 Optional, | |
42 Tuple, | |
43 ) | |
36 | 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 ( |
40 open, | 48 open, |
53 hashutil, | 61 hashutil, |
54 procutil, | 62 procutil, |
55 stringutil, | 63 stringutil, |
56 ) | 64 ) |
57 | 65 |
58 if pycompat.TYPE_CHECKING: | 66 # keeps pyflakes happy |
59 from typing import ( | 67 assert [ |
60 Iterable, | 68 Iterable, |
61 Iterator, | 69 Iterator, |
62 List, | 70 List, |
63 Optional, | 71 Optional, |
64 Tuple, | 72 Tuple, |
65 ) | 73 ] |
66 | 74 |
67 | 75 |
68 base85 = policy.importmod('base85') | 76 base85 = policy.importmod('base85') |
69 osutil = policy.importmod('osutil') | 77 osutil = policy.importmod('osutil') |
70 | 78 |