Skip to content

Commit 2a29937

Browse files
committed
fix(types): resolve mypy type errors in rollback and cli modules
- Fix rollback.py: Change __exit__ return type from bool to None (context managers that don't suppress exceptions should return None) - Fix cli.py: Add proper type annotation for settings_kwargs dict and import Any - All 168 tests passing - Mypy and ruff checks passing
1 parent 2f03945 commit 2a29937

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

python_project_deployment/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import sys
44
from pathlib import Path
5+
from typing import Any
56

67
import click
78
from pydantic import ValidationError
@@ -106,11 +107,11 @@ def main(
106107

107108
try:
108109
# Load scaffolder settings (supports .env files and env vars)
109-
settings_kwargs = {}
110+
settings_kwargs: dict[str, Any] = {}
110111
if log_level:
111112
settings_kwargs["log_level"] = log_level.upper()
112113
if dry_run:
113-
settings_kwargs["dry_run"] = True
114+
settings_kwargs["dry_run"] = dry_run
114115

115116
settings = ScaffolderSettings(**settings_kwargs)
116117

python_project_deployment/rollback.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def __exit__(
196196
exc_type: type[BaseException] | None,
197197
exc_val: BaseException | None,
198198
exc_tb: Any,
199-
) -> bool:
199+
) -> None:
200200
"""Exit context manager, executing rollback if an exception occurred.
201201
202202
Args:
@@ -205,7 +205,7 @@ def __exit__(
205205
exc_tb: Exception traceback if an exception occurred
206206
207207
Returns:
208-
False to propagate the exception (after rollback)
208+
None (always propagates exceptions)
209209
"""
210210
if exc_type is not None:
211211
logger.error(f"Exception occurred: {exc_type.__name__}: {exc_val}")
@@ -220,9 +220,6 @@ def __exit__(
220220
logger.debug("Scaffolding completed successfully, clearing rollback operations")
221221
self.clear_operations()
222222

223-
# Always propagate the original exception (if any)
224-
return False
225-
226223
def __repr__(self) -> str:
227224
"""Return detailed representation for debugging."""
228225
return (

0 commit comments

Comments
 (0)