Skip to content

Commit 6ad7006

Browse files
author
MomIsBestFriend
committed
Fixes for @jbrockmendel review V1
1 parent 4ead557 commit 6ad7006

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

Diff for: pandas/_libs/tslibs/c_timestamp.pyx

+6-6
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class NullFrequencyError(ValueError):
5454
def maybe_integer_op_deprecated(obj):
5555
# GH#22535 add/sub of integers and int-arrays is deprecated
5656
if obj.freq is not None:
57-
warnings.warn(f"Addition/subtraction of integers and integer-arrays "
57+
warnings.warn("Addition/subtraction of integers and integer-arrays "
5858
f"to {type(obj).__name__} is deprecated, "
59-
f"will be removed in a future "
60-
f"version. Instead of adding/subtracting `n`, use "
61-
f"`n * self.freq`"
59+
"will be removed in a future "
60+
"version. Instead of adding/subtracting `n`, use "
61+
"`n * self.freq`"
6262
, FutureWarning)
6363

6464

@@ -369,13 +369,13 @@ cdef class _Timestamp(datetime):
369369

370370
@property
371371
def _repr_base(self) -> str:
372-
return f'{self._date_repr} {self._time_repr}'
372+
return f"{self._date_repr} {self._time_repr}"
373373

374374
@property
375375
def _date_repr(self) -> str:
376376
# Ideal here would be self.strftime("%Y-%m-%d"), but
377377
# the datetime strftime() methods require year >= 1900
378-
return f'{self.year}-{self.month:02d}-{self.day:02d}'
378+
return f"{self.year}-{self.month:02d}-{self.day:02d}"
379379

380380
@property
381381
def _time_repr(self) -> str:

Diff for: pandas/_libs/tslibs/parsing.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ class _timelex:
707707
self.stream = instream
708708
elif getattr(instream, 'read', None) is None:
709709
raise TypeError(
710-
f'Parser must be a string or character stream, not '
711-
f'{instream.__class__.__name__}')
710+
'Parser must be a string or character stream, not '
711+
f'{type(instream).__name__}')
712712
else:
713713
self.stream = instream.read()
714714

Diff for: pandas/_libs/tslibs/period.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1275,15 +1275,15 @@ cdef object _period_strftime(int64_t value, int freq, object fmt):
12751275
if i == 0:
12761276
repl = str(quarter)
12771277
elif i == 1: # %f, 2-digit year
1278-
repl = f'{year % 100:02d}'
1278+
repl = f'{(year % 100):02d}'
12791279
elif i == 2:
12801280
repl = str(year)
12811281
elif i == 3:
1282-
repl = f'{value % 1_000:03d}'
1282+
repl = f'{(value % 1_000):03d}'
12831283
elif i == 4:
1284-
repl = f'{value % 1_000_000:06d}'
1284+
repl = f'{(value % 1_000_000):06d}'
12851285
elif i == 5:
1286-
repl = f'{value % 1_000_000_000:09d}'
1286+
repl = f'{(value % 1_000_000_000):09d}'
12871287

12881288
result = result.replace(str_extra_fmts[i], repl)
12891289

@@ -2223,7 +2223,7 @@ cdef class _Period:
22232223
"""
22242224
base, mult = get_freq_code(self.freq)
22252225
formatted = period_format(self.ordinal, base)
2226-
value = f"{formatted}"
2226+
value = str(formatted)
22272227
return value
22282228

22292229
def __setstate__(self, state):

Diff for: pandas/_libs/tslibs/strptime.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def array_strptime(object[:] values, object fmt,
139139
if is_coerce:
140140
iresult[i] = NPY_NAT
141141
continue
142-
raise ValueError(f"time data {repr(val)} does not match "
143-
f"format {repr(fmt)} (match)")
142+
raise ValueError(f"time data '{val}' does not match "
143+
f"format '{fmt}' (match)")
144144
if len(val) != found.end():
145145
if is_coerce:
146146
iresult[i] = NPY_NAT
@@ -588,8 +588,8 @@ class TimeRE(dict):
588588
else:
589589
return ''
590590
regex = '|'.join(re.escape(stuff) for stuff in to_convert)
591-
regex = f'(?P<{directive}>{regex}'
592-
return f'{regex})'
591+
regex = f'(?P<{directive}>{regex})'
592+
return regex
593593

594594
def pattern(self, format):
595595
"""

Diff for: pandas/_libs/tslibs/timedeltas.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,8 @@ cdef class _Timedelta(timedelta):
11361136
return fmt.format(**comp_dict)
11371137

11381138
def __repr__(self) -> str:
1139-
return f"Timedelta('{self._repr_base(format='long')}')"
1139+
repr_based = self._repr_base(format='long')
1140+
return f"Timedelta('{repr_based}')"
11401141

11411142
def __str__(self) -> str:
11421143
return self._repr_base(format='long')

0 commit comments

Comments
 (0)