From 4bd16cb84636d002e5e6ea1d2f7c1bfa8cd9ca63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 19:50:03 +0000 Subject: [PATCH 1/2] chore(deps-dev): bump mypy from 1.19.1 to 2.1.0 Bumps [mypy](https://github.com/python/mypy) from 1.19.1 to 2.1.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.19.1...v2.1.0) --- updated-dependencies: - dependency-name: mypy dependency-version: 2.1.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5c6c855485..91d93136d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ dev = [ "aws-sam-cli[pre-dev]", "coverage==7.14.0", "pytest-cov==7.1.0", - "mypy==1.19.1", + "mypy==2.1.0", "types-pywin32==311.0.0.20260508", "types-PyYAML==6.0.12.20250915", "types-chevron==0.14.2.20250103", From 0bde413e5d339a9e787c35d0a7b35996471634d2 Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Wed, 13 May 2026 13:36:52 -0700 Subject: [PATCH 2/2] fix: resolve mypy 2.1.0 type-check errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _METRICS: add explicit Dict[str, "Metric"] annotation (var-annotated) - lambda_authorizer.py, resource_trigger.py: drop redundant cast() that mypy 2.1 now flags after upstream stub improvements (redundant-cast) - sync_flow.py __eq__: keep the outer cast(bool, ...) since _equality_keys() returns Any, but drop the inner cast(SyncFlow, o) — mypy 2.1 narrows o via the type(o) is type(self) guard Co-Authored-By: Claude Opus 4.7 (1M context) --- samcli/lib/sync/sync_flow.py | 2 +- samcli/lib/telemetry/metric.py | 2 +- samcli/lib/utils/resource_trigger.py | 2 +- samcli/local/apigw/authorizers/lambda_authorizer.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samcli/lib/sync/sync_flow.py b/samcli/lib/sync/sync_flow.py index b7dc94ac3b..1f5fec38ad 100644 --- a/samcli/lib/sync/sync_flow.py +++ b/samcli/lib/sync/sync_flow.py @@ -347,7 +347,7 @@ def __hash__(self) -> int: def __eq__(self, o: object) -> bool: if type(o) is not type(self): return False - return cast(bool, self._equality_keys() == cast(SyncFlow, o)._equality_keys()) + return cast(bool, self._equality_keys() == o._equality_keys()) @property def log_name(self) -> str: diff --git a/samcli/lib/telemetry/metric.py b/samcli/lib/telemetry/metric.py index f573ddc446..afead773e1 100644 --- a/samcli/lib/telemetry/metric.py +++ b/samcli/lib/telemetry/metric.py @@ -42,7 +42,7 @@ No side effect will result in this as it is write-only for code outside of telemetry. Decorators should be used to minimize logic involving telemetry. """ -_METRICS = dict() +_METRICS: Dict[str, "Metric"] = dict() # Global container socket and runtime information for telemetry # This persists across context boundaries to ensure accurate telemetry reporting diff --git a/samcli/lib/utils/resource_trigger.py b/samcli/lib/utils/resource_trigger.py index 8a8774fa8a..194579837b 100644 --- a/samcli/lib/utils/resource_trigger.py +++ b/samcli/lib/utils/resource_trigger.py @@ -386,7 +386,7 @@ def _get_definition_file(self) -> str: definition_file = self._resource.get("Properties", {}).get(property_name) if not definition_file or not isinstance(definition_file, str): raise MissingLocalDefinition(self._resource_identifier, property_name) - return cast(str, definition_file) + return definition_file def _validator_wrapper(self, event: Optional[FileSystemEvent] = None): """Wrapper for callback that only executes if the definition is valid and non-trivial changes are detected. diff --git a/samcli/local/apigw/authorizers/lambda_authorizer.py b/samcli/local/apigw/authorizers/lambda_authorizer.py index eb4860b975..21450ec2a4 100644 --- a/samcli/local/apigw/authorizers/lambda_authorizer.py +++ b/samcli/local/apigw/authorizers/lambda_authorizer.py @@ -6,7 +6,7 @@ from abc import ABC, abstractmethod from dataclasses import dataclass from json import JSONDecodeError, loads -from typing import Any, Dict, List, Optional, Tuple, Type, Union, cast +from typing import Any, Dict, List, Optional, Tuple, Type, Union from urllib.parse import parse_qsl from samcli.commands.local.lib.validators.identity_source_validator import IdentitySourceValidator @@ -417,7 +417,7 @@ def _validate_simple_response(self, response: dict) -> bool: f"Authorizer {self.authorizer_name} is missing or contains an invalid " f"{_SIMPLE_RESPONSE_IS_AUTH}" ) - return cast(bool, is_authorized) + return is_authorized def get_context(self, response: Union[str, bytes]) -> Dict[str, Any]: """