Skip to content

Commit

Permalink
replace syntax with f-string (#30919)
Browse files Browse the repository at this point in the history
  • Loading branch information
HH-MWB authored and WillAyd committed Jan 11, 2020
1 parent 6e9651e commit 7f2948c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ def __arrow_array__(self, type=None):
if self.freqstr != type.freq:
raise TypeError(
"Not supported to convert PeriodArray to array with different"
" 'freq' ({0} vs {1})".format(self.freqstr, type.freq)
f" 'freq' ({self.freqstr} vs {type.freq})"
)
else:
raise TypeError(
"Not supported to convert PeriodArray to '{0}' type".format(type)
f"Not supported to convert PeriodArray to '{type}' type"
)

period_type = ArrowPeriodType(self.freqstr)
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,11 @@ def ensure_python_int(value: Union[int, np.integer]) -> int:
"""
if not is_scalar(value):
raise TypeError(f"Value needs to be a scalar value, was type {type(value)}")
msg = "Wrong type {} for value {}"
try:
new_value = int(value)
assert new_value == value
except (TypeError, ValueError, AssertionError):
raise TypeError(msg.format(type(value), value))
raise TypeError(f"Wrong type {type(value)} for value {value}")
return new_value


Expand Down
3 changes: 1 addition & 2 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,11 @@ def __eq__(self, other: Any) -> bool:
return hash(self) == hash(other)

def __repr__(self) -> str_type:
tpl = "CategoricalDtype(categories={data}ordered={ordered})"
if self.categories is None:
data = "None, "
else:
data = self.categories._format_data(name=type(self).__name__)
return tpl.format(data=data, ordered=self.ordered)
return f"CategoricalDtype(categories={data}ordered={self.ordered})"

@staticmethod
def _hash_categories(categories, ordered: Ordered = True) -> int:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ def _verbose_repr():
dtype = self.dtypes.iloc[i]
col = pprint_thing(col)

line_no = _put_str(" {num}".format(num=i), space_num)
line_no = _put_str(f" {i}", space_num)
count = ""
if show_counts:
count = counts.iloc[i]
Expand Down

0 comments on commit 7f2948c

Please sign in to comment.