1- # -*- coding: utf-8 -*-
21"""
32Provides the default implementation of :class:`ArrowFactory <arrow.factory.ArrowFactory>`
43methods for use as a module API.
54
65"""
76
8- from __future__ import absolute_import
7+ from datetime import date , datetime
8+ from datetime import tzinfo as dt_tzinfo
9+ from time import struct_time
10+ from typing import Any , List , Optional , Tuple , Type , Union , overload
911
12+ from arrow .arrow import TZ_EXPR , Arrow
13+ from arrow .constants import DEFAULT_LOCALE
1014from arrow .factory import ArrowFactory
1115
1216# internal default factory.
1317_factory = ArrowFactory ()
1418
15-
16- def get (* args , ** kwargs ):
19+ # TODO: Use Positional Only Argument (https://www.python.org/dev/peps/pep-0570/)
20+ # after Python 3.7 deprecation
21+
22+
23+ @overload
24+ def get (
25+ * ,
26+ locale : str = DEFAULT_LOCALE ,
27+ tzinfo : Optional [TZ_EXPR ] = None ,
28+ normalize_whitespace : bool = False ,
29+ ) -> Arrow :
30+ ... # pragma: no cover
31+
32+
33+ @overload
34+ def get (
35+ * args : int ,
36+ locale : str = DEFAULT_LOCALE ,
37+ tzinfo : Optional [TZ_EXPR ] = None ,
38+ normalize_whitespace : bool = False ,
39+ ) -> Arrow :
40+ ... # pragma: no cover
41+
42+
43+ @overload
44+ def get (
45+ __obj : Union [
46+ Arrow ,
47+ datetime ,
48+ date ,
49+ struct_time ,
50+ dt_tzinfo ,
51+ int ,
52+ float ,
53+ str ,
54+ Tuple [int , int , int ],
55+ ],
56+ * ,
57+ locale : str = DEFAULT_LOCALE ,
58+ tzinfo : Optional [TZ_EXPR ] = None ,
59+ normalize_whitespace : bool = False ,
60+ ) -> Arrow :
61+ ... # pragma: no cover
62+
63+
64+ @overload
65+ def get (
66+ __arg1 : Union [datetime , date ],
67+ __arg2 : TZ_EXPR ,
68+ * ,
69+ locale : str = DEFAULT_LOCALE ,
70+ tzinfo : Optional [TZ_EXPR ] = None ,
71+ normalize_whitespace : bool = False ,
72+ ) -> Arrow :
73+ ... # pragma: no cover
74+
75+
76+ @overload
77+ def get (
78+ __arg1 : str ,
79+ __arg2 : Union [str , List [str ]],
80+ * ,
81+ locale : str = DEFAULT_LOCALE ,
82+ tzinfo : Optional [TZ_EXPR ] = None ,
83+ normalize_whitespace : bool = False ,
84+ ) -> Arrow :
85+ ... # pragma: no cover
86+
87+
88+ def get (* args : Any , ** kwargs : Any ) -> Arrow :
1789 """Calls the default :class:`ArrowFactory <arrow.factory.ArrowFactory>` ``get`` method."""
1890
1991 return _factory .get (* args , ** kwargs )
@@ -22,7 +94,7 @@ def get(*args, **kwargs):
2294get .__doc__ = _factory .get .__doc__
2395
2496
25- def utcnow ():
97+ def utcnow () -> Arrow :
2698 """Calls the default :class:`ArrowFactory <arrow.factory.ArrowFactory>` ``utcnow`` method."""
2799
28100 return _factory .utcnow ()
@@ -31,7 +103,7 @@ def utcnow():
31103utcnow .__doc__ = _factory .utcnow .__doc__
32104
33105
34- def now (tz = None ):
106+ def now (tz : Optional [ TZ_EXPR ] = None ) -> Arrow :
35107 """Calls the default :class:`ArrowFactory <arrow.factory.ArrowFactory>` ``now`` method."""
36108
37109 return _factory .now (tz )
@@ -40,7 +112,7 @@ def now(tz=None):
40112now .__doc__ = _factory .now .__doc__
41113
42114
43- def factory (type ) :
115+ def factory (type : Type [ Arrow ]) -> ArrowFactory :
44116 """Returns an :class:`.ArrowFactory` for the specified :class:`Arrow <arrow.arrow.Arrow>`
45117 or derived type.
46118
0 commit comments