Skip to content

Commit

Permalink
Upgrade to ruff 0.9.1 (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos authored Jan 15, 2025
1 parent 9375ec2 commit 8510bd9
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extend-select = [
]
ignore = [
"B027",
"F821",
"N818",
"RUF003",
"RUF012",
Expand All @@ -95,6 +96,4 @@ ignore = [
"Q003",
"COM812",
"COM819",
"ISC001",
"ISC002",
]
3 changes: 1 addition & 2 deletions src/packaging/_elffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions src/packaging/_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ def _parse_glibc_version(version_str: str) -> tuple[int, int]:
m = re.match(r"(?P<major>[0-9]+)\.(?P<minor>[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,
)
Expand Down
3 changes: 1 addition & 2 deletions src/packaging/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
6 changes: 3 additions & 3 deletions src/packaging/_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/packaging/licenses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
from packaging.licenses._spdx import EXCEPTIONS, LICENSES

__all__ = [
"NormalizedLicenseExpression",
"InvalidLicenseExpression",
"NormalizedLicenseExpression",
"canonicalize_license_expression",
]

Expand Down
3 changes: 1 addition & 2 deletions src/packaging/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/packaging/specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions tests/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand Down

0 comments on commit 8510bd9

Please sign in to comment.