Context
PR #149 type-annotated `Catchment.init` and `Calibration.init`
parameters. The type-design-analyzer flagged that three constructor
parameters are annotated `str | None` with non-None defaults, but the
constructor body calls `.lower()` without a None guard.
Problem / Current Behaviour
```python
src/Hapi/catchment.py:58-60
def init(
self,
name,
start,
end,
spatial_resolution: str | None = "Lumped", # annotated | None
temporal_resolution: str | None = "Daily", # annotated | None
routing_method: str | None = "Muskingum", # annotated | None
):
# Line ~89: crashes if None is passed
if spatial_resolution.lower() == "lumped": # AttributeError!
```
Affected locations
| File |
Symbol |
Notes |
| `src/Hapi/catchment.py:58-60` |
`Catchment.init` |
3 params |
| `src/Hapi/calibration.py:41-43` |
`Calibration.init` |
Same 3 params |
Proposed Solution
Drop `| None` since the constructor doesn't handle None:
```python
spatial_resolution: str = "Lumped",
temporal_resolution: str = "Daily",
routing_method: str = "Muskingum",
```
Effort Estimate
Size: `XS`
Definition of Done
Context
PR #149 type-annotated `Catchment.init` and `Calibration.init`
parameters. The type-design-analyzer flagged that three constructor
parameters are annotated `str | None` with non-None defaults, but the
constructor body calls `.lower()` without a None guard.
Problem / Current Behaviour
```python
src/Hapi/catchment.py:58-60
def init(
self,
name,
start,
end,
spatial_resolution: str | None = "Lumped", # annotated | None
temporal_resolution: str | None = "Daily", # annotated | None
routing_method: str | None = "Muskingum", # annotated | None
):
# Line ~89: crashes if None is passed
if spatial_resolution.lower() == "lumped": # AttributeError!
```
Affected locations
Proposed Solution
Drop `| None` since the constructor doesn't handle None:
```python
spatial_resolution: str = "Lumped",
temporal_resolution: str = "Daily",
routing_method: str = "Muskingum",
```
Effort Estimate
Size: `XS`
Definition of Done