Skip to content

Commit

Permalink
Fix remaining type issues with arguments dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Mar 9, 2024
1 parent 34ac5d2 commit ed67e74
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
5 changes: 3 additions & 2 deletions pyinfra/api/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Callable,
Generic,
Iterable,
List,
Mapping,
Optional,
TypeVar,
Expand Down Expand Up @@ -169,7 +170,7 @@ class MetaArguments(TypedDict):
name: str
_ignore_errors: bool
_continue_on_error: bool
_if: list[Callable[[], bool]]
_if: List[Callable[[], bool]]


meta_argument_meta: dict[str, ArgumentMeta] = {
Expand Down Expand Up @@ -299,7 +300,7 @@ def pop_global_arguments(
if context.ctx_config.isset():
config = context.config

meta_kwargs: dict[str, Any] = cast(dict[str, Any], host.current_deploy_kwargs) or {}
meta_kwargs: dict[str, Any] = host.current_deploy_kwargs or {} # type: ignore[assignment]

arguments: dict[str, Any] = {}
found_keys: list[str] = []
Expand Down
14 changes: 12 additions & 2 deletions pyinfra/api/arguments_typed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Callable, Generator, Generic, Iterable, Mapping, Optional, Union
from typing import (
TYPE_CHECKING,
Callable,
Generator,
Generic,
Iterable,
List,
Mapping,
Optional,
Union,
)

from typing_extensions import ParamSpec, Protocol

Expand Down Expand Up @@ -51,7 +61,7 @@ def __call__(
name: Optional[str] = None,
_ignore_errors: bool = False,
_continue_on_error: bool = False,
_if: Optional[list[Callable[[], bool]]] = None,
_if: Optional[List[Callable[[], bool]]] = None,
#
# ExecutionArguments
#
Expand Down
2 changes: 1 addition & 1 deletion pyinfra/api/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
Type,
TypeVar,
Union,
Unpack,
cast,
overload,
)
from uuid import uuid4

import click
from typing_extensions import Unpack

from pyinfra import logger
from pyinfra.connectors.base import BaseConnector
Expand Down
2 changes: 1 addition & 1 deletion pyinfra/api/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def decorated_func(*args: P.args, **kwargs: P.kwargs) -> OperationMeta:
if func.deprecated_for: # type: ignore[attr-defined]
logger.warning(
f"The {get_operation_name_from_func(func)} operation is "
+ f"deprecated, please use: {func.deprecated_for}", # type: ignore[attr-defined]
+ f"deprecated, please use: {func.deprecated_for}", # type: ignore[attr-defined] # noqa
)
else:
logger.warning(f"The {get_operation_name_from_func(func)} operation is deprecated")
Expand Down
9 changes: 4 additions & 5 deletions pyinfra/api/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ def _run_host_op(state: "State", host: "Host", op_hash: str) -> Optional[bool]:
timeout = global_arguments.get("_timeout", 0)

executor_kwarg_keys = CONNECTOR_ARGUMENT_KEYS
base_connector_arguments: ConnectorArguments = (
cast( # https://github.com/python/mypy/issues/10371
ConnectorArguments,
{key: global_arguments[key] for key in executor_kwarg_keys if key in global_arguments},
)
# See: https://github.com/python/mypy/issues/10371
base_connector_arguments: ConnectorArguments = cast(
ConnectorArguments,
{key: global_arguments[key] for key in executor_kwarg_keys if key in global_arguments}, # type: ignore[literal-required] # noqa
)

did_error = False
Expand Down
3 changes: 3 additions & 0 deletions tests/words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ e501
ed25519
endian
entrypoint
envvar
epel
excuted
exe
Expand Down Expand Up @@ -343,6 +344,7 @@ status
stdlib
stringify
stringio
strs
su
subclassed
subclassing
Expand Down Expand Up @@ -383,6 +385,7 @@ ufw
uname
unignored
unmount
unresposivehost
up
up2
useradd
Expand Down

0 comments on commit ed67e74

Please sign in to comment.