Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .ci/run_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ else
fi
export PULP_CONTENT_ORIGIN

PULP_DJANGO_SECRET="$(python3 -c "import secrets; print(secrets.token_urlsafe(50))")"
export PULP_DJANGO_SECRET
PULP_SECRET_KEY="$(python3 -c "import secrets; print(secrets.token_urlsafe(50))")"
export PULP_SECRET_KEY

"${CONTAINER_RUNTIME}" \
run ${RM:+--rm} \
Expand All @@ -82,7 +82,7 @@ export PULP_DJANGO_SECRET
${PULP_DOMAIN_ENABLED:+--env PULP_DOMAIN_ENABLED} \
${PULP_ENABLED_PLUGINS:+--env PULP_ENABLED_PLUGINS} \
--env PULP_CONTENT_ORIGIN \
--env PULP_DJANGO_SECRET \
--env PULP_SECRET_KEY \
--detach \
--name "pulp-ephemeral" \
--volume "${PULP_CLI_TEST_TMPDIR}/settings:/etc/pulp${SELINUX:+:Z}" \
Expand Down
4 changes: 2 additions & 2 deletions .ci/scripts/check_cli_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def dependencies(path: Path) -> t.Iterator[Requirement]:
base_path = Path(__file__).parent.parent.parent
glue_path = base_path / GLUE_DIR

cli_dependency = next((r for r in dependencies(base_path) if r.name == "pulp-cli"))
glue_dependency = next((r for r in dependencies(glue_path) if r.name == "pulp-glue"))
cli_dependency = next(r for r in dependencies(base_path) if r.name == "pulp-cli")
glue_dependency = next(r for r in dependencies(glue_path) if r.name == "pulp-glue")

if cli_dependency.specifier != glue_dependency.specifier:
print("🪢 CLI and GLUE dependencies mismatch:")
Expand Down
4 changes: 2 additions & 2 deletions .ci/scripts/check_click_for_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# "packaging>=25.0,<25.1",
# ]
# ///

import sys
from importlib import metadata

from packaging.version import Version
Expand All @@ -15,4 +15,4 @@
if click_version < Version("8.1.1"):
print("🚧 Linting with mypy is currently only supported with click>=8.1.1. 🚧")
print("🔧 Please run `pip install click>=8.1.1` first. 🔨")
exit(1)
sys.exit(1)
12 changes: 7 additions & 5 deletions .ci/scripts/collect_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

import itertools
import re
import typing as t
from pathlib import Path

import tomllib
from git import GitCommandError, Repo
from packaging.version import Version
from packaging.version import parse as parse_version

# Read Towncrier settings
Expand Down Expand Up @@ -51,29 +53,29 @@
)


def get_changelog(repo, branch):
def get_changelog(repo: Repo, branch: str) -> str:
branch_tc_settings = tomllib.loads(repo.git.show(f"{branch}:pyproject.toml"))["tool"][
"towncrier"
]
branch_changelog_file = branch_tc_settings.get("filename", "NEWS.rst")
return repo.git.show(f"{branch}:{branch_changelog_file}") + "\n"


def _tokenize_changes(splits):
def _tokenize_changes(splits: list[str]) -> t.Iterator[list[Version | str]]:
assert len(splits) % 3 == 0
for i in range(len(splits) // 3):
title = splits[3 * i]
version = parse_version(splits[3 * i + 1])
yield [version, title + splits[3 * i + 2]]


def split_changelog(changelog):
def split_changelog(changelog: str) -> tuple[str, list[list[Version | str]]]:
preamble, rest = changelog.split(START_STRING, maxsplit=1)
split_rest = re.split(TITLE_REGEX, rest)
return preamble + START_STRING + split_rest[0], list(_tokenize_changes(split_rest[1:]))


def main():
def main() -> None:
repo = Repo(Path.cwd())
remote = repo.remotes[0]
branches = [ref for ref in remote.refs if re.match(r"^([0-9]+)\.([0-9]+)$", ref.remote_head)]
Expand All @@ -91,7 +93,7 @@ def main():
except GitCommandError:
print("No changelog found on this branch.")
continue
dummy, changes = split_changelog(changelog)
_dummy, changes = split_changelog(changelog)
new_changes = sorted(main_changes + changes, key=lambda x: x[0], reverse=True)
# Now remove duplicates (retain the first one)
main_changes = [new_changes[0]]
Expand Down
8 changes: 6 additions & 2 deletions pulp-glue-deb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
"Typing :: Typed",
]
dependencies = [
"pulp-glue<0.41,>=0.23.2",
"pulp-glue<0.41,>=0.32.4",
]

[project.urls]
Expand Down Expand Up @@ -65,5 +65,9 @@ line-length = 100
[tool.ruff.lint]
# This section is managed by the cookiecutter templates.
select = ["E4", "E7", "E9", "F"]
extend-select = ["I", "INT", "PTH"]
extend-select = ["FURB", "I", "INT", "PTH", "SIM1", "TID", "T10", "UP"]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
# This section is managed by the cookiecutter templates.
"distutils".msg = "The 'distutils' module has been deprecated since Python 3.9."

6 changes: 3 additions & 3 deletions pulp-glue-deb/src/pulp_glue/deb/context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ClassVar, Set
from typing import ClassVar

from pulp_glue.common.context import ( # type: ignore[attr-defined]
EntityDefinition,
Expand Down Expand Up @@ -145,7 +145,7 @@ def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> En


class PulpVerbatimPublicationContext(PulpEntityContext):
APT_ONLY: ClassVar[Set[str]] = {"simple", "structured", "signing_service"}
APT_ONLY: ClassVar[set[str]] = {"simple", "structured", "signing_service"}
ENTITY = _("verbatim publication")
ENTITIES = _("verbatim publications")
HREF = "deb_verbatim_publication_href"
Expand Down Expand Up @@ -190,7 +190,7 @@ def tuple_to_whitespace_separated_string(field_name: str, body: EntityDefinition
field = body.pop(field_name, None)
if field:
string_field = " ".join(field).strip()
body[field_name] = string_field if string_field else None
body[field_name] = string_field or None

def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> EntityDefinition:
body = super().preprocess_entity(body)
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers=[
"Typing :: Typed",
]
dependencies = [
"pulp-cli<0.41,>=0.23.2",
"pulp-cli<0.41,>=0.32.4",
"pulp-glue-deb==0.6.0.dev",
]

Expand Down Expand Up @@ -200,13 +200,18 @@ line-length = 100
[tool.ruff.lint]
# This section is managed by the cookiecutter templates.
select = ["E4", "E7", "E9", "F"]
extend-select = ["I", "INT", "PTH"]
extend-select = ["FURB", "I", "INT", "PTH", "SIM1", "TID", "T10", "UP"]

[tool.ruff.lint.isort]
# This section is managed by the cookiecutter templates.
sections = { second-party = ["pulp_glue"] }
section-order = ["future", "standard-library", "third-party", "second-party", "first-party", "local-folder"]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
# This section is managed by the cookiecutter templates.
"distutils".msg = "The 'distutils' module has been deprecated since Python 3.9."
"pulpcore.cli.common.generic".msg = "This module moved to 'pulp_cli.generic'."


[tool.uv.sources]
# This section is managed by the cookiecutter templates.
Expand All @@ -232,7 +237,7 @@ dev = [
lint = [
{include-group = "test"},
"mypy~=1.20.0",
"ruff~=0.15.1",
"ruff~=0.16.0",
"shellcheck-py~=0.11.0.1",
"types-pygments",
"types-pyyaml",
Expand Down
2 changes: 1 addition & 1 deletion src/pulpcore/cli/deb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any

import click
from pulpcore.cli.common.generic import pulp_group
from pulp_cli.generic import pulp_group

from pulpcore.cli.deb.content import content
from pulpcore.cli.deb.distribution import distribution
Expand Down
8 changes: 4 additions & 4 deletions src/pulpcore/cli/deb/content.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import IO, Any, Optional, Union
from typing import IO, Any

import click
from pulpcore.cli.common.generic import (
from pulp_cli.generic import (
PulpCLIContext,
chunk_size_option,
create_command,
Expand Down Expand Up @@ -56,8 +56,8 @@ def _sha256_callback(ctx: click.Context, param: click.Parameter, value: str) ->


def _sha256_artifact_callback(
ctx: click.Context, param: click.Parameter, value: Optional[str]
) -> Optional[Union[str, PulpEntityContext]]:
ctx: click.Context, param: click.Parameter, value: str | None
) -> str | PulpEntityContext | None:
# Pass None and "" verbatim
if value:
pulp_ctx = ctx.find_object(PulpCLIContext)
Expand Down
2 changes: 1 addition & 1 deletion src/pulpcore/cli/deb/distribution.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gettext

import click
from pulpcore.cli.common.generic import (
from pulp_cli.generic import (
PulpCLIContext,
base_path_contains_option,
base_path_option,
Expand Down
2 changes: 1 addition & 1 deletion src/pulpcore/cli/deb/publication.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gettext

import click
from pulpcore.cli.common.generic import (
from pulp_cli.generic import (
PulpCLIContext,
create_command,
destroy_command,
Expand Down
2 changes: 1 addition & 1 deletion src/pulpcore/cli/deb/remote.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import click
from pulpcore.cli.common.generic import (
from pulp_cli.generic import (
PulpCLIContext,
common_remote_create_options,
common_remote_update_options,
Expand Down
10 changes: 5 additions & 5 deletions src/pulpcore/cli/deb/repository.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any, Dict, Optional
from typing import Any

import click
import schema as s
from pulpcore.cli.common.generic import (
from pulp_cli.generic import (
PulpCLIContext,
create_command,
create_content_json_callback,
Expand Down Expand Up @@ -174,12 +174,12 @@ def sync(
repository_ctx: PulpRepositoryContext,
/,
remote: EntityFieldDefinition,
mirror: Optional[bool],
optimize: Optional[bool],
mirror: bool | None,
optimize: bool | None,
) -> None:
repository = repository_ctx.entity

body: Dict[str, Any] = {}
body: dict[str, Any] = {}

if mirror is not None:
body["mirror"] = mirror
Expand Down
17 changes: 8 additions & 9 deletions tests/test_help_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@
load_plugins()


def traverse_commands(command: click.Command, args: t.List[str]) -> t.Iterator[t.List[str]]:
def traverse_commands(command: click.Command, args: list[str]) -> t.Iterator[list[str]]:
yield args

if isinstance(command, click.Group):
for name, sub in command.commands.items():
yield from traverse_commands(sub, args + [name])

params = command.params
if params:
if "--type" in params[0].opts:
# iterate over commands with specific context types
assert isinstance(params[0].type, click.Choice)
for context_type in params[0].type.choices:
yield args + ["--type", context_type]
if params and "--type" in params[0].opts:
# iterate over commands with specific context types
assert isinstance(params[0].type, click.Choice)
for context_type in params[0].type.choices:
yield args + ["--type", context_type]

for name, sub in command.commands.items():
yield from traverse_commands(sub, args + ["--type", context_type, name])
for name, sub in command.commands.items():
yield from traverse_commands(sub, args + ["--type", context_type, name])


def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
Expand Down