Skip to content

Commit

Permalink
Adjust to typing improvements in click
Browse files Browse the repository at this point in the history
fixes pulp#726
  • Loading branch information
mdellweg committed Jul 20, 2023
1 parent 64d8e09 commit 8012d43
Show file tree
Hide file tree
Showing 25 changed files with 245 additions and 179 deletions.
1 change: 1 addition & 0 deletions CHANGES/726.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adjusted to typing improvements in click>=8.1.4.
12 changes: 5 additions & 7 deletions pulpcore/cli/ansible/content.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import IO, Any, Callable, Optional, Union
from typing import IO, Any, Callable, Optional

import click
from pulp_glue.ansible.context import (
Expand Down Expand Up @@ -218,7 +218,9 @@ def content(ctx: click.Context, pulp_ctx: PulpCLIContext, content_type: str) ->
content.add_command(show_command(decorators=lookup_options))


@content.command()
# This is a mypy bug getting confused with positional args
# https://github.com/python/mypy/issues/15037
@content.command() # type: ignore [arg-type]
@click.option("--file", type=click.File("rb"), required=True)
@repository_option
@pulp_option(
Expand Down Expand Up @@ -253,11 +255,7 @@ def content(ctx: click.Context, pulp_ctx: PulpCLIContext, content_type: str) ->
@pass_pulp_context
def upload(
pulp_ctx: PulpCLIContext,
content_ctx: Union[
PulpAnsibleRoleContext,
PulpAnsibleCollectionVersionContext,
PulpAnsibleCollectionVersionSignatureContext,
],
content_ctx: PulpEntityContext,
file: IO[bytes],
**kwargs: Any,
) -> None:
Expand Down
5 changes: 4 additions & 1 deletion pulpcore/cli/ansible/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
EntityFieldDefinition,
PluginRequirement,
PulpContext,
PulpEntityContext,
)
from pulp_glue.common.i18n import get_translation

Expand Down Expand Up @@ -104,7 +105,7 @@ def distribution(ctx: click.Context, pulp_ctx: PulpContext, distribution_type: s
@pulp_labels_option
@pass_entity_context
def update(
distribution_ctx: PulpAnsibleDistributionContext,
distribution_ctx: PulpEntityContext,
base_path: Optional[str],
repository: EntityFieldDefinition,
content_guard: EntityFieldDefinition,
Expand All @@ -114,6 +115,8 @@ def update(
"""
To remove repository or repository_version fields set --repository to ""
"""
assert isinstance(distribution_ctx, PulpAnsibleDistributionContext)

dist_body: EntityDefinition = distribution_ctx.entity
name: str = dist_body["name"]
body: EntityDefinition = dict()
Expand Down
4 changes: 3 additions & 1 deletion pulpcore/cli/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ def config() -> None:
pass


@config.command(help=_("Create a pulp-cli config settings file"))
# This is a mypy bug getting confused with positional args
# https://github.com/python/mypy/issues/15037
@config.command(help=_("Create a pulp-cli config settings file")) # type: ignore [arg-type]
@config_options
@click.option("--interactive", "-i", is_flag=True)
@click.option("--editor", "-e", is_flag=True, help=_("Edit the config file in an editor"))
Expand Down
Loading

0 comments on commit 8012d43

Please sign in to comment.