diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index a7eaee30930..b37b2abe950 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -199,7 +199,8 @@ def get_supported_platform(): m = macosVersionString.match(plat) if m is not None and sys.platform == "darwin": try: - plat = 'macosx-{}-{}'.format('.'.join(_macos_vers()[:2]), m.group(3)) + major_minor = '.'.join(_macos_vers()[:2]) + plat = f'macosx-{major_minor}-{m.group(3)}' except ValueError: # not macOS pass @@ -2557,7 +2558,8 @@ def __str__(self): if self.attrs: s += ':' + '.'.join(self.attrs) if self.extras: - s += ' [{}]'.format(','.join(self.extras)) + extras = ','.join(self.extras) + s += f' [{extras}]' return s def __repr__(self): diff --git a/setuptools/_core_metadata.py b/setuptools/_core_metadata.py index 86eef673fa1..2cbdb71807a 100644 --- a/setuptools/_core_metadata.py +++ b/setuptools/_core_metadata.py @@ -176,8 +176,8 @@ def write_field(key, value): if license: write_field('License', rfc822_escape(license)) - for project_url in self.project_urls.items(): - write_field('Project-URL', '{}, {}'.format(*project_url)) + for label, url in self.project_urls.items(): + write_field('Project-URL', f'{label}, {url}') keywords = ','.join(self.get_keywords()) if keywords: diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 06d28069134..f3ff897b823 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1021,7 +1021,8 @@ def install_exe(self, dist_filename, tmpdir): f.write('Metadata-Version: 1.0\n') for k, v in cfg.items('metadata'): if k != 'target_version': - f.write('{}: {}\n'.format(k.replace('_', '-').title(), v)) + k = k.replace('_', '-').title() + f.write(f'{k}: {v}\n' script_dir = os.path.join(_egg_info, 'scripts') # delete entry-point scripts to avoid duping self.delete_blockers([ diff --git a/setuptools/tests/config/test_setupcfg.py b/setuptools/tests/config/test_setupcfg.py index 6b6e347da86..0b9c7bf0082 100644 --- a/setuptools/tests/config/test_setupcfg.py +++ b/setuptools/tests/config/test_setupcfg.py @@ -92,7 +92,7 @@ def test_basic(self, tmpdir): def test_no_config(self, tmpdir): with pytest.raises(DistutilsFileError): - read_configuration('{}'.format(tmpdir.join('setup.cfg'))) + read_configuration(str(tmpdir.join('setup.cfg'))) def test_ignore_errors(self, tmpdir): _, config = fake_env( @@ -100,9 +100,9 @@ def test_ignore_errors(self, tmpdir): '[metadata]\n' 'version = attr: none.VERSION\n' 'keywords = one, two\n', ) with pytest.raises(ImportError): - read_configuration(f'{config}') + read_configuration(str(config)) - config_dict = read_configuration(f'{config}', ignore_option_errors=True) + config_dict = read_configuration(str(config), ignore_option_errors=True) assert config_dict['metadata']['keywords'] == ['one', 'two'] assert 'version' not in config_dict['metadata'] diff --git a/setuptools/tests/test_build_ext.py b/setuptools/tests/test_build_ext.py index 6ccd9ebc299..75606f1de2f 100644 --- a/setuptools/tests/test_build_ext.py +++ b/setuptools/tests/test_build_ext.py @@ -285,8 +285,8 @@ def test_build_ext_config_handling(tmpdir_cwd): ), } path.build(files) - code, output = environment.run_setup_py( + code, (stdout, stderr) = environment.run_setup_py( cmd=['build'], data_stream=(0, 2), ) - assert code == 0, '\nSTDOUT:\n{}\nSTDERR:\n{}'.format(*output) + assert code == 0, f'\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}'