@@ -179,8 +179,8 @@ cdef class IntervalMixin:
179179 When `other` is not closed exactly the same as self.
180180 """
181181 if self .closed != other.closed:
182- msg = " '{}.closed' is '{}', expected '{}'."
183- raise ValueError (msg.format(name, other.closed, self .closed) )
182+ msg = f " '{name }.closed' is '{other.closed }', expected '{self.closed }'."
183+ raise ValueError (msg)
184184
185185
186186cdef _interval_like(other):
@@ -308,17 +308,16 @@ cdef class Interval(IntervalMixin):
308308 self ._validate_endpoint(right)
309309
310310 if closed not in _VALID_CLOSED:
311- msg = " invalid option for 'closed': {closed}" .format( closed = closed)
311+ msg = f " invalid option for 'closed': {closed}"
312312 raise ValueError (msg)
313313 if not left <= right:
314314 raise ValueError (' left side of interval must be <= right side' )
315315 if (isinstance (left, Timestamp) and
316316 not tz_compare(left.tzinfo, right.tzinfo)):
317317 # GH 18538
318- msg = (" left and right must have the same time zone, got "
319- " '{left_tz}' and '{right_tz}'" )
320- raise ValueError (msg.format(left_tz = left.tzinfo,
321- right_tz = right.tzinfo))
318+ msg = (f" left and right must have the same time zone, got "
319+ f" '{left.tzinfo}' and '{right.tzinfo}'" )
320+ raise ValueError (msg)
322321 self .left = left
323322 self .right = right
324323 self .closed = closed
@@ -359,8 +358,7 @@ cdef class Interval(IntervalMixin):
359358 name = type (self ).__name__
360359 other = type (other).__name__
361360 op_str = {Py_LT: ' <' , Py_LE: ' <=' , Py_GT: ' >' , Py_GE: ' >=' }[op]
362- raise TypeError (' unorderable types: {name}() {op} {other}()'
363- .format(name = name, op = op_str, other = other))
361+ raise TypeError (f' unorderable types: {name}() {op_str} {other}()' )
364362
365363 def __reduce__ (self ):
366364 args = (self .left, self .right, self .closed)
@@ -381,17 +379,15 @@ cdef class Interval(IntervalMixin):
381379
382380 left , right = self ._repr_base()
383381 name = type (self ).__name__
384- repr_str = ' {name}({left!r}, {right!r}, closed={closed!r})' .format(
385- name = name, left = left, right = right, closed = self .closed)
382+ repr_str = f' {name}({left!r}, {right!r}, closed={self.closed!r})'
386383 return repr_str
387384
388385 def __str__(self ) -> str:
389386
390387 left , right = self ._repr_base()
391388 start_symbol = ' [' if self .closed_left else ' ('
392389 end_symbol = ' ]' if self .closed_right else ' )'
393- return '{start}{left}, {right}{end}'.format(
394- start = start_symbol, left = left, right = right, end = end_symbol)
390+ return f'{start_symbol}{left}, {right}{end_symbol}'
395391
396392 def __add__(self , y ):
397393 if isinstance (y, numbers.Number):
@@ -477,8 +473,8 @@ cdef class Interval(IntervalMixin):
477473 False
478474 """
479475 if not isinstance (other, Interval):
480- msg = ' `other` must be an Interval, got {other}'
481- raise TypeError (msg.format( other = type (other).__name__) )
476+ msg = f ' `other` must be an Interval, got {type( other).__name__ }'
477+ raise TypeError (msg)
482478
483479 # equality is okay if both endpoints are closed (overlap at a point)
484480 op1 = le if (self .closed_left and other.closed_right) else lt
@@ -529,8 +525,8 @@ def intervals_to_interval_bounds(ndarray intervals,
529525 continue
530526
531527 if not isinstance (interval, Interval):
532- raise TypeError (" type {typ } with value {iv} is not an interval "
533- .format( typ = type ( interval), iv = interval) )
528+ raise TypeError (f " type {type(interval) } with value "
529+ f " { interval} is not an interval" )
534530
535531 left[i] = interval.left
536532 right[i] = interval.right
0 commit comments