Skip to content

Commit 2208c40

Browse files
kpmccahillWillAyd
authored andcommitted
CLN: .format to f-string formatting in various files (#30294)
1 parent 68b3eb4 commit 2208c40

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

pandas/_config/config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ def register_option(key: str, defval: object, doc="", validator=None, cb=None):
462462

463463
cursor = _global_config
464464
msg = "Path prefix to option '{option}' is already an option"
465+
465466
for i, p in enumerate(path[:-1]):
466467
if not isinstance(cursor, dict):
467468
raise OptionError(msg.format(option=".".join(path[:i])))
@@ -650,8 +651,9 @@ def _build_option_description(k):
650651
s += f"\n [default: {o.defval}] [currently: {_get_option(k, True)}]"
651652

652653
if d:
654+
rkey = d.rkey if d.rkey else ""
653655
s += "\n (Deprecated"
654-
s += ", use `{rkey}` instead.".format(rkey=d.rkey if d.rkey else "")
656+
s += f", use `{rkey}` instead."
655657
s += ")"
656658

657659
return s

pandas/_config/localization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,6 @@ def get_locales(prefix=None, normalize=True, locale_getter=_default_locale_gette
161161
if prefix is None:
162162
return _valid_locales(out_locales, normalize)
163163

164-
pattern = re.compile("{prefix}.*".format(prefix=prefix))
164+
pattern = re.compile(f"{prefix}.*")
165165
found = pattern.findall("\n".join(out_locales))
166166
return _valid_locales(found, normalize)

setup.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def is_platform_mac():
3939
"install_requires": [
4040
"python-dateutil >= 2.6.1",
4141
"pytz >= 2017.2",
42-
"numpy >= {numpy_ver}".format(numpy_ver=min_numpy_ver),
42+
f"numpy >= {min_numpy_ver}",
4343
],
44-
"setup_requires": ["numpy >= {numpy_ver}".format(numpy_ver=min_numpy_ver)],
44+
"setup_requires": [f"numpy >= {min_numpy_ver}"],
4545
"zip_safe": False,
4646
}
4747

@@ -364,10 +364,8 @@ def run(self):
364364
for pyxfile in pyxfiles:
365365
sourcefile = pyxfile[:-3] + extension
366366
msg = (
367-
"{extension}-source file '{source}' not found.\n"
368-
"Run 'setup.py cython' before sdist.".format(
369-
source=sourcefile, extension=extension
370-
)
367+
f"{extension}-source file '{sourcefile}' not found.\n"
368+
f"Run 'setup.py cython' before sdist."
371369
)
372370
assert os.path.isfile(sourcefile), msg
373371
sdist_class.run(self)
@@ -382,14 +380,12 @@ def check_cython_extensions(self, extensions):
382380
for ext in extensions:
383381
for src in ext.sources:
384382
if not os.path.exists(src):
385-
print("{}: -> [{}]".format(ext.name, ext.sources))
383+
print(f"{ext.name}: -> [{ext.sources}]")
386384
raise Exception(
387-
"""Cython-generated file '{src}' not found.
385+
f"""Cython-generated file '{src}' not found.
388386
Cython is required to compile pandas from a development branch.
389387
Please install Cython or download a release package of pandas.
390-
""".format(
391-
src=src
392-
)
388+
"""
393389
)
394390

395391
def build_extensions(self):
@@ -706,7 +702,7 @@ def srcpath(name=None, suffix=".pyx", subdir="src"):
706702
include = data.get("include")
707703

708704
obj = Extension(
709-
"pandas.{name}".format(name=name),
705+
f"pandas.{name}",
710706
sources=sources,
711707
depends=data.get("depends", []),
712708
include_dirs=include,

0 commit comments

Comments
 (0)