diff --git a/pyproject.toml b/pyproject.toml index 9b7ec873..2871ce5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,10 +97,13 @@ exclude_also = [ extend-select = [ "ANN", # flake8-annotations "B", # flake8-bugbear + "FLY", # flynt "G", # flake8-logging-format "I", # isort "ISC", # flake8-implicit-str-concat + "PERF", # Perflint "PGH", # pygrep-hooks + "PIE", # flake8-pie "RUF100", # unused noqa (yesqa) "UP", # pyupgrade "W", # pycodestyle warnings diff --git a/src/wheel/_bdist_wheel.py b/src/wheel/_bdist_wheel.py index 575fbfb3..a71bd942 100644 --- a/src/wheel/_bdist_wheel.py +++ b/src/wheel/_bdist_wheel.py @@ -274,7 +274,7 @@ def finalize_options(self): egg_info = self.distribution.get_command_obj("egg_info") egg_info.ensure_finalized() # needed for correct `wheel_dist_name` - self.data_dir = self.wheel_dist_name + ".data" + self.data_dir = f"{self.wheel_dist_name}.data" self.plat_name_supplied = self.plat_name is not None try: @@ -447,7 +447,7 @@ def run(self): if not os.path.exists(self.dist_dir): os.makedirs(self.dist_dir) - wheel_path = os.path.join(self.dist_dir, archive_basename + ".whl") + wheel_path = os.path.join(self.dist_dir, f"{archive_basename}.whl") with WheelFile(wheel_path, "w", self.compression) as wf: wf.write_files(archive_root) @@ -485,7 +485,7 @@ def write_wheelfile( for impl in impl_tag.split("."): for abi in abi_tag.split("."): for plat in plat_tag.split("."): - msg["Tag"] = "-".join((impl, abi, plat)) + msg["Tag"] = f"{impl}-{abi}-{plat}" wheelfile_path = os.path.join(wheelfile_base, "WHEEL") log.info(f"creating {wheelfile_path}") diff --git a/src/wheel/_commands/tags.py b/src/wheel/_commands/tags.py index cec896b5..600ff94c 100644 --- a/src/wheel/_commands/tags.py +++ b/src/wheel/_commands/tags.py @@ -48,7 +48,7 @@ def tags( with WheelFile(wheel, "r") as f: assert f.filename, f"{f.filename} must be available" - wheel_info = f.read(f.dist_info_path + "/WHEEL") + wheel_info = f.read(f"{f.dist_info_path}/WHEEL") info = BytesParser(policy=email.policy.compat32).parsebytes(wheel_info) original_wheel_name = os.path.basename(f.filename) @@ -127,9 +127,9 @@ def tags( for item in fin.infolist(): if item.is_dir(): continue - if item.filename == f.dist_info_path + "/RECORD": + if item.filename == f"{f.dist_info_path}/RECORD": continue - if item.filename == f.dist_info_path + "/WHEEL": + if item.filename == f"{f.dist_info_path}/WHEEL": fout.writestr(item, info.as_bytes()) else: fout.writestr(item, fin.read(item)) diff --git a/src/wheel/_metadata.py b/src/wheel/_metadata.py index e17a7b92..2835dca5 100644 --- a/src/wheel/_metadata.py +++ b/src/wheel/_metadata.py @@ -91,9 +91,9 @@ def requires_to_requires_dist(requirement: Requirement) -> str: if requirement.url: return " @ " + requirement.url - requires_dist: list[str] = [] - for spec in requirement.specifier: - requires_dist.append(spec.operator + spec.version) + requires_dist: list[str] = [ + spec.operator + spec.version for spec in requirement.specifier + ] if requires_dist: return " " + ",".join(sorted(requires_dist)) @@ -133,7 +133,7 @@ def generate_requirements( if extra: yield "Provides-Extra", extra if condition: - condition = "(" + condition + ") and " + condition = f"({condition}) and " condition += f"extra == '{extra}'" if condition: diff --git a/src/wheel/macosx_libfile.py b/src/wheel/macosx_libfile.py index 06e51af2..82055195 100644 --- a/src/wheel/macosx_libfile.py +++ b/src/wheel/macosx_libfile.py @@ -440,7 +440,7 @@ def calculate_macosx_platform_tag(archive_root: StrPath, platform_tag: str) -> s versions_dict: dict[str, tuple[int, int]] = {} for dirpath, _dirnames, filenames in os.walk(archive_root): for filename in filenames: - if filename.endswith(".dylib") or filename.endswith(".so"): + if filename.endswith((".dylib", ".so")): lib_path = os.path.join(dirpath, filename) min_ver = extract_macosx_min_system_version(lib_path) if min_ver is not None: @@ -482,5 +482,5 @@ def calculate_macosx_platform_tag(archive_root: StrPath, platform_tag: str) -> s sys.stderr.write(error_message) - platform_tag = prefix + "_" + fin_base_version + "_" + suffix + platform_tag = f"{prefix}_{fin_base_version}_{suffix}" return platform_tag diff --git a/src/wheel/wheelfile.py b/src/wheel/wheelfile.py index 7b6fd716..eec7c2b4 100644 --- a/src/wheel/wheelfile.py +++ b/src/wheel/wheelfile.py @@ -78,14 +78,14 @@ def __init__( self.dist_info_path = "{}.dist-info".format( self.parsed_filename.group("namever") ) - self.record_path = self.dist_info_path + "/RECORD" + self.record_path = f"{self.dist_info_path}/RECORD" self._file_hashes: dict[str, tuple[None, None] | tuple[int, bytes]] = {} self._file_sizes = {} if mode == "r": # Ignore RECORD and any embedded wheel signatures self._file_hashes[self.record_path] = None, None - self._file_hashes[self.record_path + ".jws"] = None, None - self._file_hashes[self.record_path + ".p7s"] = None, None + self._file_hashes[f"{self.record_path}.jws"] = None, None + self._file_hashes[f"{self.record_path}.p7s"] = None, None # Fill in the expected hashes by reading them from RECORD try: @@ -231,7 +231,7 @@ def close(self) -> None: writer = csv.writer(data, delimiter=",", quotechar='"', lineterminator="\n") writer.writerows( ( - (fname, algorithm + "=" + hash_, self._file_sizes[fname]) + (fname, f"{algorithm}={hash_}", self._file_sizes[fname]) for fname, (algorithm, hash_) in self._file_hashes.items() ) ) diff --git a/tests/commands/test_tags.py b/tests/commands/test_tags.py index f73b1175..dd677682 100644 --- a/tests/commands/test_tags.py +++ b/tests/commands/test_tags.py @@ -35,7 +35,7 @@ def test_python_tags(wheelpath: Path) -> None: assert newname == TESTWHEEL_NAME.replace("py2.py3", "py3") output_file = wheelpath.parent / newname with WheelFile(output_file) as f: - output = f.read(f.dist_info_path + "/WHEEL") + output = f.read(f"{f.dist_info_path}/WHEEL") assert ( output == b"Wheel-Version: 1.0\nGenerator: bdist_wheel (0.30.0)" @@ -161,7 +161,7 @@ def test_multi_tags(wheelpath: Path) -> None: output_file = wheelpath.parent / newname assert output_file.exists() with WheelFile(output_file) as f: - output = f.read(f.dist_info_path + "/WHEEL") + output = f.read(f"{f.dist_info_path}/WHEEL") assert output == ( b"Wheel-Version: 1.0\n"