diff --git a/pyproject.toml b/pyproject.toml index 5c6c855485e..91d93136d1f 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", diff --git a/samcli/lib/sync/sync_flow.py b/samcli/lib/sync/sync_flow.py index b7dc94ac3b7..1f5fec38ade 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 f573ddc4467..afead773e18 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 8a8774fa8ab..194579837b7 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 eb4860b9754..21450ec2a4a 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]: """