Skip to content

Commit

Permalink
Add project name by default to already_handled_packages (#202)
Browse files Browse the repository at this point in the history
Add inter-relative extra dependency and test it.

Use inter-relative dependency for the `dev` extra to install
`docs` and `testing` also.
  • Loading branch information
CasperWA committed Oct 25, 2023
1 parent 3455ecc commit 3f0821e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion ci_cd/tasks/update_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ def update_deps( # pylint: disable=too-many-branches,too-many-locals,too-many-s
)
py_version = match.group("version")

already_handled_packages = set()
# Skip package if it is this project (this can happen for inter-relative extra
# dependencies)
already_handled_packages = {pyproject["project"]["name"]}

updated_packages = {}
dependencies = pyproject.get("project", {}).get("dependencies", [])
for optional_deps in (
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ testing = [
dev = [
"pre-commit ~=2.21",
"pylint ~=2.13",
"ci-cd[docs,testing]",
]

[project.urls]
Expand Down
13 changes: 10 additions & 3 deletions tests/tasks/test_update_deps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Test `ci_cd.tasks.update_deps()`."""
# pylint: disable=line-too-long,too-many-lines,too-many-locals
# pylint: disable=line-too-long,too-many-lines,too-many-locals,too-many-branches
from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down Expand Up @@ -34,6 +34,7 @@ def test_update_deps(tmp_path: "Path", caplog: pytest.LogCaptureFixture) -> None
pyproject_file.write_text(
data=f"""
[project]
name = "test"
requires-python = "~=3.7"
dependencies = [
Expand All @@ -51,10 +52,9 @@ def test_update_deps(tmp_path: "Path", caplog: pytest.LogCaptureFixture) -> None
]
dev = [
"mike >={original_dependencies['mike']},<3",
"pytest ~={original_dependencies['pytest']}",
"pytest-cov ~={original_dependencies['pytest-cov']}",
"pre-commit ~={original_dependencies['pre-commit']}",
"pylint ~={original_dependencies['pylint']}",
"test[testing]",
]
# List from https://peps.python.org/pep-0508/#complete-grammar
Expand Down Expand Up @@ -161,6 +161,12 @@ def test_update_deps(tmp_path: "Path", caplog: pytest.LogCaptureFixture) -> None
"'name5 [fred,bar]' is pinned to a URL and will be skipped"
in caplog.text
)
elif "test[testing]" in line:
assert line == "test[testing]"
assert (
"'test[testing]' is not version restricted and will be skipped."
not in caplog.text
)
else:
pytest.fail(f"Unknown package in line: {line}")

Expand Down Expand Up @@ -1100,6 +1106,7 @@ def test_ignore_rules_logic(
pyproject_file.write_text(
data=f"""
[project]
name = "test"
requires-python = "~=3.7"
dependencies = [
Expand Down

0 comments on commit 3f0821e

Please sign in to comment.