diff --git a/pandas/_config/config.py b/pandas/_config/config.py index 8f75d0381c1a6..9e74eb46f7b1f 100644 --- a/pandas/_config/config.py +++ b/pandas/_config/config.py @@ -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]))) @@ -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 diff --git a/pandas/_config/localization.py b/pandas/_config/localization.py index ba60b1e003004..dd1d4948aa6e3 100644 --- a/pandas/_config/localization.py +++ b/pandas/_config/localization.py @@ -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) diff --git a/setup.py b/setup.py index e42a570200dc3..38fc57e4f80bf 100755 --- a/setup.py +++ b/setup.py @@ -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, } @@ -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) @@ -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): @@ -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,