comparison mercurial/error.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 bf16ef96defe
children 81224afd938d
comparison
equal deleted inserted replaced
51301:58d39c7865e5 51302:9d3721552b6c
12 """ 12 """
13 13
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 AnyStr, 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):
33 # type: (...) -> bytes 44 # type: (...) -> bytes
34 """Byte-stringify exception in the same way as BaseException_str()""" 45 """Byte-stringify exception in the same way as BaseException_str()"""