Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/logcmdutil.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 | d6e5bec550f1 |
children | f15cb5111a1e |
comparison
equal
deleted
inserted
replaced
51301:58d39c7865e5 | 51302:9d3721552b6c |
---|---|
7 | 7 |
8 | 8 |
9 import itertools | 9 import itertools |
10 import os | 10 import os |
11 import posixpath | 11 import posixpath |
12 | |
13 from typing import ( | |
14 Any, | |
15 Callable, | |
16 Dict, | |
17 Optional, | |
18 Sequence, | |
19 Tuple, | |
20 ) | |
12 | 21 |
13 from .i18n import _ | 22 from .i18n import _ |
14 from .node import wdirrev | 23 from .node import wdirrev |
15 | 24 |
16 from .thirdparty import attr | 25 from .thirdparty import attr |
37 from .utils import ( | 46 from .utils import ( |
38 dateutil, | 47 dateutil, |
39 stringutil, | 48 stringutil, |
40 ) | 49 ) |
41 | 50 |
42 | 51 # keeps pyflakes happy |
43 if pycompat.TYPE_CHECKING: | 52 assert [ |
44 from typing import ( | 53 Any, |
45 Any, | 54 Callable, |
46 Callable, | 55 Dict, |
47 Dict, | 56 Optional, |
48 Optional, | 57 Sequence, |
49 Sequence, | 58 Tuple, |
50 Tuple, | 59 ] |
51 ) | 60 |
52 | 61 # keep pyflakes happy |
53 for t in (Any, Callable, Dict, Optional, Tuple): | 62 for t in (Any, Callable, Dict, Optional, Tuple): |
54 assert t | 63 assert t |
55 | 64 |
56 | 65 |
57 def getlimit(opts): | 66 def getlimit(opts): |
58 """get the log limit according to option -l/--limit""" | 67 """get the log limit according to option -l/--limit""" |
59 limit = opts.get(b'limit') | 68 limit = opts.get(b'limit') |