From 91af8ba36857260d0d4724557db3115769689e37 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 08:56:30 -0400 Subject: [PATCH] Update dependency pyright to ^1.1.382 (#2575) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Kyle Finley --- package-lock.json | 14 +++++++------- package.json | 2 +- runway/cfngin/blueprints/base.py | 2 ++ runway/cfngin/dag/__init__.py | 2 +- runway/cfngin/hooks/docker/hook_data.py | 2 +- runway/cfngin/hooks/docker/image/_build.py | 2 +- runway/cfngin/hooks/ssm/parameter.py | 8 ++++---- runway/cfngin/lookups/handlers/file.py | 12 ++++++++---- runway/cfngin/plan.py | 2 +- runway/context/_runway.py | 2 +- runway/core/components/_module_path.py | 2 +- runway/env_mgr/tfenv.py | 6 +++--- 12 files changed, 31 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index b77e475f6..5391b821f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "devDependencies": { "cspell": "^8.14.4", - "pyright": "^1.1.377" + "pyright": "^1.1.382" } }, "node_modules/@cspell/cspell-bundled-dicts": { @@ -1156,9 +1156,9 @@ } }, "node_modules/pyright": { - "version": "1.1.377", - "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.377.tgz", - "integrity": "sha512-y6ENYuyZXTczPnPWZnqx78pE+ZgyIotEas2M/LFRTq3EfbgVk84EcvuSKLIy2DJeDKjKDxVP/LVmDNHabljD3g==", + "version": "1.1.382", + "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.382.tgz", + "integrity": "sha512-AsTbuh5OiV12GpWqSrekJHWj+dP4KEdB69rBh8Nr+n4OHeXKr5hFtGDksrlhcIGFW6WouHvZERkwA12FHPwWOg==", "dev": true, "bin": { "pyright": "index.js", @@ -2244,9 +2244,9 @@ "dev": true }, "pyright": { - "version": "1.1.377", - "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.377.tgz", - "integrity": "sha512-y6ENYuyZXTczPnPWZnqx78pE+ZgyIotEas2M/LFRTq3EfbgVk84EcvuSKLIy2DJeDKjKDxVP/LVmDNHabljD3g==", + "version": "1.1.382", + "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.382.tgz", + "integrity": "sha512-AsTbuh5OiV12GpWqSrekJHWj+dP4KEdB69rBh8Nr+n4OHeXKr5hFtGDksrlhcIGFW6WouHvZERkwA12FHPwWOg==", "dev": true, "requires": { "fsevents": "~2.3.3" diff --git a/package.json b/package.json index 14aeaa9ee..3543805d2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "devDependencies": { "cspell": "^8.14.4", - "pyright": "^1.1.377" + "pyright": "^1.1.382" }, "name": "runway", "version": "0.0.0" diff --git a/runway/cfngin/blueprints/base.py b/runway/cfngin/blueprints/base.py index efe5fbe27..bd0f800ef 100644 --- a/runway/cfngin/blueprints/base.py +++ b/runway/cfngin/blueprints/base.py @@ -47,6 +47,8 @@ class CFNParameter: """Wrapper around a value to indicate a CloudFormation Parameter.""" + value: list[Any] | str + def __init__(self, name: str, value: bool | float | list[Any] | str | Any) -> None: """Instantiate class. diff --git a/runway/cfngin/dag/__init__.py b/runway/cfngin/dag/__init__.py index 9ccfd7c7e..af6e954e6 100644 --- a/runway/cfngin/dag/__init__.py +++ b/runway/cfngin/dag/__init__.py @@ -306,7 +306,7 @@ def from_dict(self, graph_dict: dict[str, Iterable[str] | Any]) -> None: for ind_node, dep_nodes in graph_dict.items(): if not isinstance(dep_nodes, collections.abc.Iterable): raise TypeError(f"{ind_node}: dict values must be lists") - for dep_node in dep_nodes: + for dep_node in cast("list[str]", dep_nodes): self.add_edge(ind_node, dep_node) def reset_graph(self) -> None: diff --git a/runway/cfngin/hooks/docker/hook_data.py b/runway/cfngin/hooks/docker/hook_data.py index 0275f45a8..93b6d0c24 100644 --- a/runway/cfngin/hooks/docker/hook_data.py +++ b/runway/cfngin/hooks/docker/hook_data.py @@ -25,7 +25,7 @@ def client(self) -> DockerClient: return DockerClient.from_env() @overload - def update_context(self, context: CfnginContext = ...) -> DockerHookData: ... + def update_context(self, context: CfnginContext) -> DockerHookData: ... @overload def update_context(self, context: None = ...) -> None: ... diff --git a/runway/cfngin/hooks/docker/image/_build.py b/runway/cfngin/hooks/docker/image/_build.py index 90dbc34bb..547136165 100644 --- a/runway/cfngin/hooks/docker/image/_build.py +++ b/runway/cfngin/hooks/docker/image/_build.py @@ -135,7 +135,7 @@ def _set_docker( v.setdefault("tag", repo) elif isinstance(v, DockerImageBuildApiOptions) and not v.tag: v.tag = repo - return v + return v # pyright: ignore[reportUnknownVariableType] @field_validator("ecr_repo", mode="before") @classmethod diff --git a/runway/cfngin/hooks/ssm/parameter.py b/runway/cfngin/hooks/ssm/parameter.py index df2f7a848..a69375f31 100644 --- a/runway/cfngin/hooks/ssm/parameter.py +++ b/runway/cfngin/hooks/ssm/parameter.py @@ -110,10 +110,10 @@ def _convert_policies(cls, v: list[dict[str, Any]] | str | Any) -> str: @classmethod def _convert_tags(cls, v: dict[str, str] | list[dict[str, str]] | Any) -> list[dict[str, str]]: """Convert tags to acceptable value.""" - if isinstance(v, list): - return v - if isinstance(v, dict): - return [{"Key": k, "Value": v} for k, v in v.items()] + if isinstance(v, list): # TODO (kyle): improve with `typing.TypeIs` narrowing + return cast("list[dict[str, str]]", v) + if isinstance(v, dict): # TODO (kyle): improve with `typing.TypeIs` narrowing + return [{"Key": k, "Value": v} for k, v in cast("dict[str, str]", v).items()] raise ValueError( f"unexpected type {type(v)}; permitted: dict[str, str] | list[dict[str, str]] | none" ) diff --git a/runway/cfngin/lookups/handlers/file.py b/runway/cfngin/lookups/handlers/file.py index 2f5f57c43..66f1acb42 100644 --- a/runway/cfngin/lookups/handlers/file.py +++ b/runway/cfngin/lookups/handlers/file.py @@ -6,7 +6,7 @@ import collections.abc import json import re -from typing import TYPE_CHECKING, Any, Callable, ClassVar, overload +from typing import TYPE_CHECKING, Any, Callable, ClassVar, cast, overload import yaml from pydantic import field_validator @@ -121,7 +121,7 @@ def parameterized_codec(raw: str, b64: Literal[False] = ...) -> GenericHelperFn: @overload -def parameterized_codec(raw: str, b64: Literal[True] = ...) -> Base64: ... +def parameterized_codec(raw: str, b64: Literal[True]) -> Base64: ... def parameterized_codec(raw: str, b64: bool = False) -> Any: @@ -175,9 +175,13 @@ def _parameterize_obj( if isinstance(obj, str): return _parameterize_string(obj) if isinstance(obj, collections.abc.Mapping): - return {key: _parameterize_obj(value) for key, value in obj.items()} + # TODO (kyle): improve with `typing.TypeIs` narrowing + return { + key: _parameterize_obj(value) for key, value in cast("Mapping[str, Any]", obj).items() + } if isinstance(obj, collections.abc.Sequence): - return [_parameterize_obj(item) for item in obj] + # TODO (kyle): improve with `typing.TypeIs` narrowing + return [_parameterize_obj(item) for item in cast("Sequence[Any]", obj)] return obj diff --git a/runway/cfngin/plan.py b/runway/cfngin/plan.py index c32d8aa87..bf6af43b3 100644 --- a/runway/cfngin/plan.py +++ b/runway/cfngin/plan.py @@ -50,7 +50,7 @@ def json_serial(obj: set[Any] | Any) -> Any: """ if isinstance(obj, set): - return list(obj) + return list(obj) # pyright: ignore[reportUnknownArgumentType] raise TypeError diff --git a/runway/context/_runway.py b/runway/context/_runway.py index 8f360dd54..16d4fd088 100644 --- a/runway/context/_runway.py +++ b/runway/context/_runway.py @@ -65,7 +65,7 @@ def no_color(self) -> bool: """ colorize = self.env.vars.get("RUNWAY_COLORIZE") # explicitly enable/disable try: - if isinstance(colorize, bool): + if isinstance(colorize, bool): # pyright: ignore[reportUnnecessaryIsInstance] # catch False return not colorize if colorize and isinstance(colorize, str): # type: ignore diff --git a/runway/core/components/_module_path.py b/runway/core/components/_module_path.py index 4eff846a1..e7b5d5c3a 100644 --- a/runway/core/components/_module_path.py +++ b/runway/core/components/_module_path.py @@ -158,7 +158,7 @@ def parse_obj( definition=obj.path, deploy_environment=deploy_environment, ) - if isinstance(obj, (type(None), Path, str)): + if isinstance(obj, (type(None), Path, str)): # pyright: ignore[reportUnnecessaryIsInstance] return cls( cache_dir=cache_dir, definition=obj, diff --git a/runway/env_mgr/tfenv.py b/runway/env_mgr/tfenv.py index f5ad4efa8..c5b7719ee 100644 --- a/runway/env_mgr/tfenv.py +++ b/runway/env_mgr/tfenv.py @@ -198,9 +198,9 @@ def _flatten_lists(data: dict[str, Any] | list[Any] | Any) -> dict[str, Any] | A data: Dict with lists to flatten. """ - if not isinstance(data, dict): + if not isinstance(data, dict): # TODO (kyle): improve with `typing.TypeIs` narrowing return data - copy_data = data.copy() + copy_data = cast("dict[str, Any]", data).copy() for attr, val in copy_data.items(): if isinstance(val, list): if len(cast("list[Any]", val)) == 1: @@ -210,7 +210,7 @@ def _flatten_lists(data: dict[str, Any] | list[Any] | Any) -> dict[str, Any] | A data[attr] = [_flatten_lists(v) for v in cast("list[Any]", val)] elif isinstance(val, dict): data[attr] = _flatten_lists(cast("dict[str, Any]", val)) - return data + return cast("dict[str, Any]", data) try: result: dict[str, Any] | list[dict[str, Any]] = load_terraform_module(