Mercurial > public > mercurial-scm > hg-stable
diff mercurial/subrepoutil.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 |
line wrap: on
line diff
--- a/mercurial/subrepoutil.py Wed Nov 08 01:58:16 2023 +0100 +++ b/mercurial/subrepoutil.py Wed Dec 20 12:51:20 2023 +0100 @@ -9,6 +9,16 @@ import os import posixpath import re +import typing + +from typing import ( + Any, + Dict, + List, + Optional, + Set, + Tuple, +) from .i18n import _ from . import ( @@ -17,7 +27,6 @@ filemerge, pathutil, phases, - pycompat, util, ) from .utils import ( @@ -25,17 +34,19 @@ urlutil, ) +# keeps pyflakes happy +assert [ + Any, + Dict, + List, + Optional, + Set, + Tuple, +] + nullstate = (b'', b'', b'empty') -if pycompat.TYPE_CHECKING: - from typing import ( - Any, - Dict, - List, - Optional, - Set, - Tuple, - ) +if typing.TYPE_CHECKING: from . import ( context, localrepo, @@ -45,7 +56,17 @@ ui as uimod, ) - Substate = Dict[bytes, Tuple[bytes, bytes, bytes]] + # keeps pyflakes happy + assert [ + context, + localrepo, + matchmod, + scmutil, + subrepo, + uimod, + ] + +Substate = Dict[bytes, Tuple[bytes, bytes, bytes]] def state(ctx, ui):