You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5318eaf
Browse filesBrowse the repository at this point in the historyBrowse files
fix(resilience): defer __init__.py re-exports until Task 7
The original scaffold's __init__.py imported Retry and RetryBudget before
either class existed, which both broke ruff F401 and would have raised
ImportError at module load time during the intermediate tasks (Tasks 4-6
import from httpware.middleware.resilience.budget, which triggers parent
__init__.py execution).
Defer the re-exports to Task 7 once both classes are defined; update the
plan to reflect this. Pure dev-loop fix, no behavior change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Then create each file with the contents below. Use the Write tool, not bash heredocs.
65
65
66
-
`src/httpware/middleware/resilience/__init__.py`:
66
+
`src/httpware/middleware/resilience/__init__.py` (docstring-only — re-exports defer to Task 7 so intermediate tasks can `import httpware.middleware.resilience.budget` without tripping an import-time `ImportError` from this `__init__.py`):
67
67
```python
68
-
"""Resilience primitives: Retry middleware and RetryBudget token bucket."""
68
+
"""Resilience primitives: Retry middleware and RetryBudget token bucket.
69
69
70
-
from httpware.middleware.resilience.budget import RetryBudget
71
-
from httpware.middleware.resilience.retry import Retry
70
+
Re-exports land in Task 7 once both classes exist; until then this file is
71
+
docstring-only so that importing ``httpware.middleware.resilience.budget``
72
+
during the intermediate tasks does not trip an import-time ``ImportError``.
73
+
"""
72
74
```
73
75
74
76
`src/httpware/middleware/resilience/budget.py`:
@@ -1029,15 +1031,30 @@ class Retry:
1029
1031
Run: `uv run pytest tests/test_retry.py -v`
1030
1032
Expected: all PASS.
1031
1033
1032
-
-[ ]**Step 4: Lint**
1034
+
-[ ]**Step 4: Wire `Retry` + `RetryBudget` into `resilience/__init__.py`**
1033
1035
1034
-
Run: `uv run ruff check src/httpware/middleware/resilience/retry.py tests/test_retry.py && uv run ty check src/httpware/middleware/resilience/retry.py`
1036
+
Now that both classes exist, replace `src/httpware/middleware/resilience/__init__.py` with:
1037
+
```python
1038
+
"""Resilience primitives: Retry middleware and RetryBudget token bucket."""
1039
+
1040
+
from httpware.middleware.resilience.budget import RetryBudget
1041
+
from httpware.middleware.resilience.retry import Retry
1042
+
1043
+
1044
+
__all__= ["Retry", "RetryBudget"]
1045
+
```
1046
+
1047
+
The `__all__` is required to silence ruff F401 ("imported but unused") and matches the pattern used by `httpware/__init__.py` and `httpware/decoders/__init__.py`.
1048
+
1049
+
-[ ]**Step 5: Lint**
1050
+
1051
+
Run: `uv run ruff check src/httpware/middleware/resilience/ tests/test_retry.py && uv run ty check src/httpware/middleware/resilience/`
1035
1052
Expected: clean. If ruff flags `Callable` / `Awaitable` import paths, adjust per existing project pattern (see `middleware/__init__.py` which uses `from collections.abc import Awaitable, Callable`).
0 commit comments