comparison mercurial/utils/dateutil.py @ 51285: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 faccec1edc2c
children f15cb5111a1e
comparison
equal deleted inserted replaced
51284:58d39c7865e5 51285:9d3721552b6c
8 8
9 import calendar 9 import calendar
10 import datetime 10 import datetime
11 import time 11 import time
12 12
13 from typing import (
14 Callable,
15 Dict,
16 Iterable,
17 Optional,
18 Tuple,
19 Union,
20 )
21
13 from ..i18n import _ 22 from ..i18n import _
14 from .. import ( 23 from .. import (
15 encoding, 24 encoding,
16 error, 25 error,
17 pycompat, 26 pycompat,
18 ) 27 )
19 28
20 if pycompat.TYPE_CHECKING: 29 # keeps pyflakes happy
21 from typing import ( 30 assert [
22 Callable, 31 Callable,
23 Dict, 32 Dict,
24 Iterable, 33 Iterable,
25 Optional, 34 Optional,
26 Tuple, 35 Tuple,
27 Union, 36 Union,
28 ) 37 ]
29 38
30 hgdate = Tuple[float, int] # (unixtime, offset) 39 hgdate = Tuple[float, int] # (unixtime, offset)
31 40
32 # used by parsedate 41 # used by parsedate
33 defaultdateformats = ( 42 defaultdateformats = (
34 b'%Y-%m-%dT%H:%M:%S', # the 'real' ISO8601 43 b'%Y-%m-%dT%H:%M:%S', # the 'real' ISO8601
35 b'%Y-%m-%dT%H:%M', # without seconds 44 b'%Y-%m-%dT%H:%M', # without seconds