Skip to content

Commit

Permalink
Merge pull request #23 from jpopelka/pre-commit
Browse files Browse the repository at this point in the history
Pre-commit updates
  • Loading branch information
jpopelka authored Jan 15, 2025
2 parents c8406b4 + 20377ca commit c2eba64
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 50 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
rev: v0.9.1
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -22,13 +22,13 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.14.1
hooks:
- id: mypy
additional_dependencies: [types-requests, types-six]
exclude: docs/conf.py
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
rev: v4.0.0-alpha.8
hooks:
- id: prettier
- repo: https://github.com/packit/pre-commit-hooks
Expand All @@ -37,4 +37,4 @@ repos:
- id: validate-config

ci:
autoupdate_schedule: monthly
autoupdate_schedule: quarterly
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ source = "vcs"
raw-options.version_scheme = "no-guess-dev"

[tool.ruff]
select = [
lint.select = [
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
Expand All @@ -74,7 +74,7 @@ select = [
"UP", # pyupgrade
"W", # pycodestyle Warning
]
ignore = [
lint.ignore = [
"SIM115", # open-file-with-context-handler
]

Expand Down
3 changes: 1 addition & 2 deletions rpmdeplint/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,7 @@ def find_conflicts(self) -> list[str]:
# set of packages under test) to catch problems like
# bug 1502458.
logger.debug(
"Skipping further checks on %s "
"to save network bandwidth",
"Skipping further checks on %s to save network bandwidth",
filename,
)
filenames.remove(filename)
Expand Down
2 changes: 1 addition & 1 deletion rpmdeplint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def add_subparser(
except argparse.ArgumentTypeError as exc:
parser.error(str(exc))
except (UnreadablePackageError, RepoDownloadError, PackageDownloadError) as exc:
sys.stderr.write("%s\n" % exc)
sys.stderr.write(f"{exc}\n")
return ExitCode.ERROR


Expand Down
10 changes: 5 additions & 5 deletions rpmdeplint/repodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ def download_repodata_file(checksum: str, urls: list[str]) -> BinaryIO:

filepath_in_cache: Path = Cache.entry_path(checksum)
if filepath_in_cache.is_file():
f = filepath_in_cache.open(mode="rb")
fr = filepath_in_cache.open(mode="rb")
logger.debug("Using cached file %s for %s", filepath_in_cache, urls[0])
# Bump the modtime on the cache file we are using,
# since our cache expiry is LRU based on modtime.
os.utime(f.fileno())
return f
os.utime(fr.fileno())
return fr

filepath_in_cache.parent.mkdir(parents=True, exist_ok=True)
fd, temp_path = mkstemp(dir=filepath_in_cache.parent, text=False)
Expand Down Expand Up @@ -194,8 +194,8 @@ def substitute_yumvars(s: str, _yumvars: dict[str, str]) -> str:
)
else:
raise ValueError(
"Yum config section %s has no "
"baseurl or metalink or mirrorlist" % section
f"Yum config section {section} has no "
"baseurl or metalink or mirrorlist."
)

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def stop(self):
@property
def url(self):
host, port = self.server_address
return "http://%s:%i" % (host, port)
return f"http://{host}:{port}"


class DirServer(WSGIServer):
Expand Down Expand Up @@ -83,7 +83,7 @@ def __call__(self, environ, start_response):
return []


@pytest.fixture()
@pytest.fixture
def dir_server():
"""
Defines an HTTP test server for listing directory contents.
Expand Down
21 changes: 9 additions & 12 deletions tests/acceptance/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,15 @@ def cleanUp():
+ [p.get_built_rpm("i386") for p in test_packages]
)
assert exitcode == 3
assert (
err
== (
"Problems with dependency set:\n"
"nothing provides doesnotexist needed by e-1.0-1.i386\n"
"Dependency problems with repos:\n"
"package d-0.1-1.i386 requires libfoo.so.4, but none of the providers can be installed\n" # noqa: E501
"Undeclared file conflicts:\n"
"f-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"Upgrade problems:\n"
"a-4.0-1.i386 would be upgraded by a-5.0-1.i386 from repo base\n"
)
assert err == (
"Problems with dependency set:\n"
"nothing provides doesnotexist needed by e-1.0-1.i386\n"
"Dependency problems with repos:\n"
"package d-0.1-1.i386 requires libfoo.so.4, but none of the providers can be installed\n" # noqa: E501
"Undeclared file conflicts:\n"
"f-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"Upgrade problems:\n"
"a-4.0-1.i386 would be upgraded by a-5.0-1.i386 from repo base\n"
)


Expand Down
29 changes: 13 additions & 16 deletions tests/acceptance/test_check_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,17 @@ def cleanUp():
]
)
assert exitcode == 3
assert (
err
== (
"Undeclared file conflicts:\n"
"x-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"x-0.1-1.i386 provides /usr/share/thing which is also provided by y-0.1-1.i386\n" # noqa: E501
"x-0.1-1.i386 provides /usr/share/thing which is also provided by z-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by x-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by z-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by x-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by y-0.1-1.i386\n" # noqa: E501
)
assert err == (
"Undeclared file conflicts:\n"
"x-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"x-0.1-1.i386 provides /usr/share/thing which is also provided by y-0.1-1.i386\n" # noqa: E501
"x-0.1-1.i386 provides /usr/share/thing which is also provided by z-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by x-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by z-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by x-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by y-0.1-1.i386\n" # noqa: E501
)


Expand Down Expand Up @@ -451,7 +448,7 @@ def test_finds_conflict_against_older_subpackage(request, dir_server):
sourceFile=SourceFile("vim.1", "oldcontent\n"),
subpackageSuffix="common",
)
oldvim.get_subpackage("minimal").section_files += "/%s\n" % conflicting_path
oldvim.get_subpackage("minimal").section_files += f"/{conflicting_path}\n"
baserepo = YumRepoBuild([oldvim])
baserepo.make("x86_64")
dir_server.basepath = baserepo.repoDir
Expand All @@ -464,7 +461,7 @@ def test_finds_conflict_against_older_subpackage(request, dir_server):
sourceFile=SourceFile("vim.1", "newcontent\n"),
subpackageSuffix="common",
)
newvim.get_subpackage("minimal").section_files += "/%s\n" % conflicting_path
newvim.get_subpackage("minimal").section_files += f"/{conflicting_path}\n"
newvim.make()

def cleanUp():
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_list_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def cleanUp():
assert exitcode == 0
assert err == ""
assert out == (
"a-0.1-1.i386 has 2 dependencies:\n" "\ta-0.1-1.i386\n" "\tb-0.1-1.i386\n\n"
"a-0.1-1.i386 has 2 dependencies:\n\ta-0.1-1.i386\n\tb-0.1-1.i386\n\n"
)


Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_dependency_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ def test_repos(self) -> None:
dependency_set = da.try_to_install_all()
assert False is dependency_set.is_ok
assert len(dependency_set.overall_problems) == 1
assert [
assert dependency_set.package_dependencies["lemon-meringue-pie-1-0.x86_64"][
"problems"
] == [
"nothing provides egg-whites needed by lemon-meringue-pie-1-0.x86_64",
"nothing provides egg-whites needed by lemon-meringue-pie-1-0.x86_64",
] == dependency_set.package_dependencies["lemon-meringue-pie-1-0.x86_64"][
"problems"
]

eggs = SimpleRpmBuild("eggs", "1", "3", ["noarch"])
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_repodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from rpmdeplint.repodata import Repo, RepoDownloadError


@pytest.fixture()
@pytest.fixture
def yumdir(tmp_path, monkeypatch):
monkeypatch.setattr(Repo, "yum_repos_d", tmp_path)
return tmp_path
Expand Down

0 comments on commit c2eba64

Please sign in to comment.