3434
3535try :
3636 from typing import Type , Any , Union , Optional , Tuple , Sequence , List
37+
3738 NotImplementedType = Type [NotImplemented ]
3839except ImportError :
3940 pass
@@ -76,14 +77,18 @@ def _cmp(obj_x: Any, obj_y: Any) -> int:
7677 return 0 if obj_x == obj_y else 1 if obj_x > obj_y else - 1
7778
7879
79- def _cmperror (obj_x : Union ["datetime" , "timedelta" ], obj_y : Union ["datetime" , "timedelta" ]) -> None :
80+ def _cmperror (
81+ obj_x : Union ["datetime" , "timedelta" ], obj_y : Union ["datetime" , "timedelta" ]
82+ ) -> None :
8083 raise TypeError (
8184 "can't compare '%s' to '%s'" % (type (obj_x ).__name__ , type (obj_y ).__name__ )
8285 )
8386
8487
8588# Utility functions - time
86- def _check_time_fields (hour : int , minute : int , second : int , microsecond : int , fold : int ) -> None :
89+ def _check_time_fields (
90+ hour : int , minute : int , second : int , microsecond : int , fold : int
91+ ) -> None :
8792 if not isinstance (hour , int ):
8893 raise TypeError ("Hour expected as int" )
8994 if not 0 <= hour <= 23 :
@@ -200,7 +205,15 @@ def _ymd2ord(year: int, month: int, day: int) -> int:
200205
201206
202207# pylint: disable=too-many-arguments
203- def _build_struct_time (tm_year : int , tm_month : int , tm_mday : int , tm_hour : int , tm_min : int , tm_sec : int , tm_isdst : int ) -> _time .struct_time :
208+ def _build_struct_time (
209+ tm_year : int ,
210+ tm_month : int ,
211+ tm_mday : int ,
212+ tm_hour : int ,
213+ tm_min : int ,
214+ tm_sec : int ,
215+ tm_isdst : int ,
216+ ) -> _time .struct_time :
204217 tm_wday = (_ymd2ord (tm_year , tm_month , tm_mday ) + 6 ) % 7
205218 tm_yday = _days_before_month (tm_year , tm_month ) + tm_mday
206219 return _time .struct_time (
@@ -313,7 +326,7 @@ class timedelta:
313326 def __new__ (
314327 cls ,
315328 days : int = 0 ,
316- seconds :int = 0 ,
329+ seconds : int = 0 ,
317330 microseconds : int = 0 ,
318331 milliseconds : int = 0 ,
319332 minutes : int = 0 ,
@@ -692,7 +705,12 @@ def today(cls) -> "date":
692705 return cls .fromtimestamp (_time .time ())
693706
694707 # Instance Methods
695- def replace (self , year : Optional [int ] = None , month : Optional [int ] = None , day : Optional [int ] = None ):
708+ def replace (
709+ self ,
710+ year : Optional [int ] = None ,
711+ month : Optional [int ] = None ,
712+ day : Optional [int ] = None ,
713+ ):
696714 """Return a date with the same value, except for those parameters
697715 given new values by whichever keyword arguments are specified.
698716 If no keyword arguments are specified - values are obtained from
@@ -799,7 +817,9 @@ class timezone(tzinfo):
799817 # Sentinel value to disallow None
800818 _Omitted = object ()
801819
802- def __new__ (cls , offset : timedelta , name : Union [str , object ] = _Omitted ) -> "timezone" :
820+ def __new__ (
821+ cls , offset : timedelta , name : Union [str , object ] = _Omitted
822+ ) -> "timezone" :
803823 if not isinstance (offset , timedelta ):
804824 raise TypeError ("offset must be a timedelta" )
805825 if name is cls ._Omitted :
@@ -890,7 +910,16 @@ class time:
890910 """
891911
892912 # pylint: disable=redefined-outer-name
893- def __new__ (cls , hour : int = 0 , minute : int = 0 , second : int = 0 , microsecond : int = 0 , tzinfo : Optional [tzinfo ] = None , * , fold : int = 0 ) -> "time" :
913+ def __new__ (
914+ cls ,
915+ hour : int = 0 ,
916+ minute : int = 0 ,
917+ second : int = 0 ,
918+ microsecond : int = 0 ,
919+ tzinfo : Optional [tzinfo ] = None ,
920+ * ,
921+ fold : int = 0
922+ ) -> "time" :
894923 _check_time_fields (hour , minute , second , microsecond , fold )
895924 _check_tzinfo_arg (tzinfo )
896925 self = object .__new__ (cls )
@@ -1330,7 +1359,9 @@ def _fromtimestamp(cls, t: float, utc: bool, tz: Optional["tzinfo"]) -> "datetim
13301359
13311360 ## pylint: disable=arguments-differ
13321361 @classmethod
1333- def fromtimestamp (cls , timestamp : float , tz : Optional ["tzinfo" ] = None ) -> "datetime" :
1362+ def fromtimestamp (
1363+ cls , timestamp : float , tz : Optional ["tzinfo" ] = None
1364+ ) -> "datetime" :
13341365 return cls ._fromtimestamp (timestamp , tz is not None , tz )
13351366
13361367 @classmethod
@@ -1357,7 +1388,7 @@ def fromisoformat(cls, date_string: str) -> "datetime":
13571388 return cls .combine (dateval , timeval )
13581389
13591390 @classmethod
1360- def now (cls , timezone : Optional ["tzinfo" ]= None ) -> "datetime" :
1391+ def now (cls , timezone : Optional ["tzinfo" ] = None ) -> "datetime" :
13611392 """Return the current local date and time."""
13621393 return cls .fromtimestamp (_time .time (), tz = timezone )
13631394
0 commit comments