1- # -*- coding: utf-8 -*-
2- from __future__ import absolute_import
3- from __future__ import division
4-
51import calendar
62import datetime
73
@@ -350,7 +346,7 @@ def _to_string(self, fmt: str, locale: Optional[str] = None) -> str:
350346 Format the instance to a common string format.
351347 """
352348 if fmt not in self ._FORMATS :
353- raise ValueError ("Format [{}] is not supported" . format ( fmt ) )
349+ raise ValueError (f "Format [{ fmt } ] is not supported" )
354350
355351 fmt = self ._FORMATS [fmt ]
356352 if callable (fmt ):
@@ -364,7 +360,7 @@ def __str__(self) -> str:
364360 def __repr__ (self ) -> str :
365361 us = ""
366362 if self .microsecond :
367- us = ", {}" . format ( self .microsecond )
363+ us = f ", { self .microsecond } "
368364
369365 repr_ = "{klass}(" "{year}, {month}, {day}, " "{hour}, {minute}, {second}{us}"
370366
@@ -665,9 +661,9 @@ def start_of(self, unit: str) -> "DateTime":
665661 * century: date to first day of century and time to 00:00:00
666662 """
667663 if unit not in self ._MODIFIERS_VALID_UNITS :
668- raise ValueError ('Invalid unit "{}" for start_of()' . format ( unit ) )
664+ raise ValueError (f 'Invalid unit "{ unit } " for start_of()' )
669665
670- return getattr (self , "_start_of_{}" . format ( unit ) )()
666+ return getattr (self , f "_start_of_{ unit } " )()
671667
672668 def end_of (self , unit : str ) -> "DateTime" :
673669 """
@@ -884,9 +880,9 @@ def first_of(self, unit: str, day_of_week: Optional[int] = None) -> "DateTime":
884880 Supported units are month, quarter and year.
885881 """
886882 if unit not in ["month" , "quarter" , "year" ]:
887- raise ValueError ('Invalid unit "{}" for first_of()' . format ( unit ) )
883+ raise ValueError (f 'Invalid unit "{ unit } " for first_of()' )
888884
889- return getattr (self , "_first_of_{}" . format ( unit ) )(day_of_week )
885+ return getattr (self , f "_first_of_{ unit } " )(day_of_week )
890886
891887 def last_of (self , unit : str , day_of_week : Optional [int ] = None ) -> "DateTime" :
892888 """
@@ -898,9 +894,9 @@ def last_of(self, unit: str, day_of_week: Optional[int] = None) -> "DateTime":
898894 Supported units are month, quarter and year.
899895 """
900896 if unit not in ["month" , "quarter" , "year" ]:
901- raise ValueError ('Invalid unit "{}" for first_of()' . format ( unit ) )
897+ raise ValueError (f 'Invalid unit "{ unit } " for first_of()' )
902898
903- return getattr (self , "_last_of_{}" . format ( unit ) )(day_of_week )
899+ return getattr (self , f "_last_of_{ unit } " )(day_of_week )
904900
905901 def nth_of (self , unit : str , nth : int , day_of_week : int ) -> "DateTime" :
906902 """
@@ -913,9 +909,9 @@ def nth_of(self, unit: str, nth: int, day_of_week: int) -> "DateTime":
913909 Supported units are month, quarter and year.
914910 """
915911 if unit not in ["month" , "quarter" , "year" ]:
916- raise ValueError ('Invalid unit "{}" for first_of()' . format ( unit ) )
912+ raise ValueError (f 'Invalid unit "{ unit } " for first_of()' )
917913
918- dt = getattr (self , "_nth_of_{}" . format ( unit ) )(nth , day_of_week )
914+ dt = getattr (self , f "_nth_of_{ unit } " )(nth , day_of_week )
919915 if dt is False :
920916 raise PendulumException (
921917 "Unable to find occurence {} of {} in {}" .format (
0 commit comments