Skip to content

CLN: .format to f-string formatting in various files #30294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class option_context:
Examples
--------

>>> with option_context('display.max_rows', 10, 'display.max_columns', 5):
with option_context('display.max_rows', 10, 'display.max_columns', 5):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought those were some characters I had accidentally added, but now that I look at the master I realize they're supposed to be there, oops

... ...
"""

Expand Down Expand Up @@ -462,6 +462,7 @@ def register_option(key: str, defval: object, doc="", validator=None, cb=None):

cursor = _global_config
msg = "Path prefix to option '{option}' is already an option"

for i, p in enumerate(path[:-1]):
if not isinstance(cursor, dict):
raise OptionError(msg.format(option=".".join(path[:i])))
Expand Down Expand Up @@ -650,8 +651,9 @@ def _build_option_description(k):
s += f"\n [default: {o.defval}] [currently: {_get_option(k, True)}]"

if d:
rkey = d.rkey if d.rkey else ""
s += "\n (Deprecated"
s += ", use `{rkey}` instead.".format(rkey=d.rkey if d.rkey else "")
s += f", use `{rkey}` instead."
s += ")"

return s
Expand Down
2 changes: 1 addition & 1 deletion pandas/_config/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,6 @@ def get_locales(prefix=None, normalize=True, locale_getter=_default_locale_gette
if prefix is None:
return _valid_locales(out_locales, normalize)

pattern = re.compile("{prefix}.*".format(prefix=prefix))
pattern = re.compile(f"{prefix}.*")
found = pattern.findall("\n".join(out_locales))
return _valid_locales(found, normalize)
20 changes: 8 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def is_platform_mac():
"install_requires": [
"python-dateutil >= 2.6.1",
"pytz >= 2017.2",
"numpy >= {numpy_ver}".format(numpy_ver=min_numpy_ver),
f"numpy >= {min_numpy_ver}",
],
"setup_requires": ["numpy >= {numpy_ver}".format(numpy_ver=min_numpy_ver)],
"setup_requires": [f"numpy >= {min_numpy_ver}"],
"zip_safe": False,
}

Expand Down Expand Up @@ -364,10 +364,8 @@ def run(self):
for pyxfile in pyxfiles:
sourcefile = pyxfile[:-3] + extension
msg = (
"{extension}-source file '{source}' not found.\n"
"Run 'setup.py cython' before sdist.".format(
source=sourcefile, extension=extension
)
f"{extension}-source file '{sourcefile}' not found.\n"
f"Run 'setup.py cython' before sdist."
)
assert os.path.isfile(sourcefile), msg
sdist_class.run(self)
Expand All @@ -382,14 +380,12 @@ def check_cython_extensions(self, extensions):
for ext in extensions:
for src in ext.sources:
if not os.path.exists(src):
print("{}: -> [{}]".format(ext.name, ext.sources))
print(f"{ext.name}: -> [{ext.sources}]")
raise Exception(
"""Cython-generated file '{src}' not found.
f"""Cython-generated file '{src}' not found.
Cython is required to compile pandas from a development branch.
Please install Cython or download a release package of pandas.
""".format(
src=src
)
"""
)

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

obj = Extension(
"pandas.{name}".format(name=name),
f"pandas.{name}",
sources=sources,
depends=data.get("depends", []),
include_dirs=include,
Expand Down