diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e4db59a..068b2e69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: additional_dependencies: [pyparsing, nox] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.11 + rev: v0.9.1 hooks: - id: ruff args: [ --fix ] diff --git a/pyproject.toml b/pyproject.toml index 985fd180..12db2105 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,7 @@ extend-select = [ ] ignore = [ "B027", + "F821", "N818", "RUF003", "RUF012", @@ -95,6 +96,4 @@ ignore = [ "Q003", "COM812", "COM819", - "ISC001", - "ISC002", ] diff --git a/src/packaging/_elffile.py b/src/packaging/_elffile.py index 25f4282c..7a5afc33 100644 --- a/src/packaging/_elffile.py +++ b/src/packaging/_elffile.py @@ -69,8 +69,7 @@ def __init__(self, f: IO[bytes]) -> None: }[(self.capacity, self.encoding)] except KeyError as e: raise ELFInvalid( - f"unrecognized capacity ({self.capacity}) or " - f"encoding ({self.encoding})" + f"unrecognized capacity ({self.capacity}) or encoding ({self.encoding})" ) from e try: diff --git a/src/packaging/_manylinux.py b/src/packaging/_manylinux.py index 61339a6f..95f55762 100644 --- a/src/packaging/_manylinux.py +++ b/src/packaging/_manylinux.py @@ -161,8 +161,7 @@ def _parse_glibc_version(version_str: str) -> tuple[int, int]: m = re.match(r"(?P[0-9]+)\.(?P[0-9]+)", version_str) if not m: warnings.warn( - f"Expected glibc version with 2 components major.minor," - f" got: {version_str}", + f"Expected glibc version with 2 components major.minor, got: {version_str}", RuntimeWarning, stacklevel=2, ) diff --git a/src/packaging/_parser.py b/src/packaging/_parser.py index c1238c06..0007c0aa 100644 --- a/src/packaging/_parser.py +++ b/src/packaging/_parser.py @@ -349,6 +349,5 @@ def _parse_marker_op(tokenizer: Tokenizer) -> Op: return Op(tokenizer.read().text) else: return tokenizer.raise_syntax_error( - "Expected marker operator, one of " - "<=, <, !=, ==, >=, >, ~=, ===, in, not in" + "Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in" ) diff --git a/src/packaging/_tokenizer.py b/src/packaging/_tokenizer.py index 89d04160..4cef3a2c 100644 --- a/src/packaging/_tokenizer.py +++ b/src/packaging/_tokenizer.py @@ -119,9 +119,9 @@ def check(self, name: str, *, peek: bool = False) -> bool: another check. If `peek` is set to `True`, the token is not loaded and would need to be checked again. """ - assert ( - self.next_token is None - ), f"Cannot check for {name!r}, already have {self.next_token!r}" + assert self.next_token is None, ( + f"Cannot check for {name!r}, already have {self.next_token!r}" + ) assert name in self.rules, f"Unknown token name: {name!r}" expression = self.rules[name] diff --git a/src/packaging/licenses/__init__.py b/src/packaging/licenses/__init__.py index 569156d6..6f7f9e62 100644 --- a/src/packaging/licenses/__init__.py +++ b/src/packaging/licenses/__init__.py @@ -37,8 +37,8 @@ from packaging.licenses._spdx import EXCEPTIONS, LICENSES __all__ = [ - "NormalizedLicenseExpression", "InvalidLicenseExpression", + "NormalizedLicenseExpression", "canonicalize_license_expression", ] diff --git a/src/packaging/metadata.py b/src/packaging/metadata.py index 721f411c..3bd8602d 100644 --- a/src/packaging/metadata.py +++ b/src/packaging/metadata.py @@ -678,8 +678,7 @@ def _process_license_files(self, value: list[str]) -> list[str]: ) if pathlib.PureWindowsPath(path).as_posix() != path: raise self._invalid_metadata( - f"{path!r} is invalid for {{field}}, " - "paths must use '/' delimiter" + f"{path!r} is invalid for {{field}}, paths must use '/' delimiter" ) paths.append(path) return paths diff --git a/src/packaging/specifiers.py b/src/packaging/specifiers.py index b30926af..c8448043 100644 --- a/src/packaging/specifiers.py +++ b/src/packaging/specifiers.py @@ -816,8 +816,7 @@ def __and__(self, other: SpecifierSet | str) -> SpecifierSet: specifier._prereleases = self._prereleases else: raise ValueError( - "Cannot combine SpecifierSets with True and False prerelease " - "overrides." + "Cannot combine SpecifierSets with True and False prerelease overrides." ) return specifier diff --git a/tests/test_markers.py b/tests/test_markers.py index cf08b99e..faf0d13b 100644 --- a/tests/test_markers.py +++ b/tests/test_markers.py @@ -290,20 +290,17 @@ def test_environment_with_extra_none(self): True, ), ( - "python_version ~= '2.7.0' and (os_name == 'foo' or " - "os_name == 'bar')", + "python_version ~= '2.7.0' and (os_name == 'foo' or os_name == 'bar')", {"os_name": "foo", "python_version": "2.7.4"}, True, ), ( - "python_version ~= '2.7.0' and (os_name == 'foo' or " - "os_name == 'bar')", + "python_version ~= '2.7.0' and (os_name == 'foo' or os_name == 'bar')", {"os_name": "bar", "python_version": "2.7.4"}, True, ), ( - "python_version ~= '2.7.0' and (os_name == 'foo' or " - "os_name == 'bar')", + "python_version ~= '2.7.0' and (os_name == 'foo' or os_name == 'bar')", {"os_name": "other", "python_version": "2.7.4"}, False, ), @@ -350,8 +347,7 @@ def test_parses_pep345_valid(self, marker_string): False, ), ( - "python_version == '2.5' and platform.python_implementation" - "!= 'Jython'", + "python_version == '2.5' and platform.python_implementation!= 'Jython'", {"python_version": "2.7"}, False, ),