Skip to content

Commit

Permalink
Manual fixes after ruff check --fix runs
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Oct 31, 2024
1 parent 444a545 commit 9c449ca
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
11 changes: 7 additions & 4 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ 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])
build = m.group(3)
plat = f'macosx-{major_minor}-{build}'
except ValueError:
# not macOS
pass
Expand Down Expand Up @@ -2738,7 +2740,8 @@ def __str__(self) -> str:
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) -> str:
Expand Down Expand Up @@ -3324,8 +3327,8 @@ def check_version_conflict(self):
):
continue
issue_warning(
f"Module {modname} was already imported from {fn}, but {self.location} is being added"
" to sys.path",
f"Module {modname} was already imported from {fn}, "
f"but {self.location} is being added to sys.path",
)

def has_version(self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions setuptools/_core_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,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:
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __bootstrap__():


class bdist_egg(Command):
description = "create an \"egg\" distribution"
description = 'create an "egg" distribution'

user_options = [
('bdist-dir=', 'b', "temporary directory for creating the distribution"),
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_ext_filename(self, fullname: str) -> str:
if not isinstance(ext_suffix, str):
raise OSError(
"Configuration variable EXT_SUFFIX not found for this platform "
+ "and environment variable SETUPTOOLS_EXT_SUFFIX is missing"
"and environment variable SETUPTOOLS_EXT_SUFFIX is missing"
)
so_ext = ext_suffix

Expand Down
7 changes: 4 additions & 3 deletions setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class easy_install(Command):
(
'optimize=',
'O',
"also compile with optimization: -O1 for \"python -O\", "
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]",
'also compile with optimization: -O1 for "python -O", '
'-O2 for "python -OO", and -O0 to disable [default: -O0]',
),
('record=', None, "filename in which to record list of installed files"),
('always-unzip', 'Z', "don't install as a zipfile, no matter what"),
Expand Down Expand Up @@ -1025,7 +1025,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([
Expand Down
3 changes: 1 addition & 2 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def check_nsp(dist, attr, value):
for nsp in ns_packages:
if not dist.has_contents_for(nsp):
raise DistutilsSetupError(
"Distribution contains no modules or packages for "
+ f"namespace package {nsp!r}"
f"Distribution contains no modules or packages for namespace package {nsp!r}"
)
parent, sep, child = nsp.rpartition('.')
if parent and parent not in ns_packages:
Expand Down
8 changes: 4 additions & 4 deletions setuptools/tests/config/test_setupcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,24 @@ def test_basic(self, tmpdir):
'[options]\n'
'scripts = bin/a.py, bin/b.py\n',
)
config_dict = read_configuration(f'{config}')
config_dict = read_configuration(str(config))
assert config_dict['metadata']['version'] == '10.1.1'
assert config_dict['metadata']['keywords'] == ['one', 'two']
assert config_dict['options']['scripts'] == ['bin/a.py', 'bin/b.py']

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(
tmpdir,
'[metadata]\nversion = attr: none.VERSION\nkeywords = 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']
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,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}'

0 comments on commit 9c449ca

Please sign in to comment.