Mercurial > public > mercurial-scm > hg
comparison mercurial/state.py @ 51282: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 | 8ced4ca30ea1 |
children | f15cb5111a1e |
comparison
equal
deleted
inserted
replaced
51281:58d39c7865e5 | 51282:9d3721552b6c |
---|---|
18 """ | 18 """ |
19 | 19 |
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: |
43 """a wrapper class to store the state of commands like `rebase`, `graft`, | 42 """a wrapper class to store the state of commands like `rebase`, `graft`, |
44 `histedit`, `shelve` etc. Extensions can also use this to write state files. | 43 `histedit`, `shelve` etc. Extensions can also use this to write state files. |