mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
review: typehint Optional locals around _parse_thickness_mm call sites
PR feedback (dancafc): `_parse_thickness_mm` handles a None input and returns Optional[int], so its call-return locals — and the Optional[str] raws they read from `_local_val` — read clearer when annotated. Annotates `thickness_raw`/`ins_thickness_raw: Optional[str]` and `thickness_mm`/`insulation_thickness_mm: Optional[int]` at all four call sites (_wall_details_from_lines, _alternative_walls_from_lines, _roof_details_from_lines, _floor_details_from_lines), plus the adjacent `u_val_raw`/`default_u` Optional pair in _floor_details_from_lines for consistency. Matches the project convention of typehinting call-return locals. No behaviour change; pyright clean, 569 parser tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
218840db98
commit
c882cb2c95
1 changed files with 14 additions and 12 deletions
|
|
@ -269,8 +269,8 @@ class ElmhurstSiteNotesExtractor:
|
|||
)
|
||||
|
||||
def _wall_details_from_lines(self, lines: List[str]) -> WallDetails:
|
||||
thickness_raw = self._local_val(lines, "Wall Thickness")
|
||||
thickness_mm = (
|
||||
thickness_raw: Optional[str] = self._local_val(lines, "Wall Thickness")
|
||||
thickness_mm: Optional[int] = (
|
||||
int(thickness_raw.split()[0]) if thickness_raw else None
|
||||
)
|
||||
# Composite / retrofit insulation thickness — Summary §7.0
|
||||
|
|
@ -280,8 +280,8 @@ class ElmhurstSiteNotesExtractor:
|
|||
# is local-scoped inside the §7 block so it does not collide
|
||||
# with the §8 Roofs / §9 Floors blocks. None when the PDF
|
||||
# omits the line (no retrofit lodged).
|
||||
ins_thickness_raw = self._local_val(lines, "Insulation Thickness")
|
||||
insulation_thickness_mm = self._parse_thickness_mm(ins_thickness_raw)
|
||||
ins_thickness_raw: Optional[str] = self._local_val(lines, "Insulation Thickness")
|
||||
insulation_thickness_mm: Optional[int] = self._parse_thickness_mm(ins_thickness_raw)
|
||||
return WallDetails(
|
||||
wall_type=self._local_str(lines, "Type"),
|
||||
insulation=self._local_str(lines, "Insulation"),
|
||||
|
|
@ -318,8 +318,10 @@ class ElmhurstSiteNotesExtractor:
|
|||
continue
|
||||
if area <= 0:
|
||||
continue
|
||||
thickness_raw = self._local_val(lines, f"Alternative Wall {n} Thickness")
|
||||
thickness_mm = self._parse_thickness_mm(thickness_raw)
|
||||
thickness_raw: Optional[str] = self._local_val(
|
||||
lines, f"Alternative Wall {n} Thickness"
|
||||
)
|
||||
thickness_mm: Optional[int] = self._parse_thickness_mm(thickness_raw)
|
||||
result.append(AlternativeWall(
|
||||
area_m2=area,
|
||||
wall_type=self._local_str(lines, f"Alternative Wall {n} Type"),
|
||||
|
|
@ -365,8 +367,8 @@ class ElmhurstSiteNotesExtractor:
|
|||
return int(match.group()) if match else None
|
||||
|
||||
def _roof_details_from_lines(self, lines: List[str]) -> RoofDetails:
|
||||
thickness_raw = self._local_val(lines, "Insulation Thickness")
|
||||
thickness_mm = self._parse_thickness_mm(thickness_raw)
|
||||
thickness_raw: Optional[str] = self._local_val(lines, "Insulation Thickness")
|
||||
thickness_mm: Optional[int] = self._parse_thickness_mm(thickness_raw)
|
||||
insulation = self._local_str(lines, "Insulation")
|
||||
# The Summary PDF omits the "Insulation Thickness" line entirely
|
||||
# when no retrofit insulation is lodged (e.g. "Insulation: N None"
|
||||
|
|
@ -390,14 +392,14 @@ class ElmhurstSiteNotesExtractor:
|
|||
return self._roof_details_from_lines(lines)
|
||||
|
||||
def _floor_details_from_lines(self, lines: List[str]) -> FloorDetails:
|
||||
u_val_raw = self._local_val(lines, "Default U-value")
|
||||
default_u = float(u_val_raw) if u_val_raw else None
|
||||
u_val_raw: Optional[str] = self._local_val(lines, "Default U-value")
|
||||
default_u: Optional[float] = float(u_val_raw) if u_val_raw else None
|
||||
# RdSAP 10 §5.13 Table 20 — retro-fitted upper floors lodge an
|
||||
# "Insulation Thickness: NNN mm" cell so the cascade can route
|
||||
# via the per-thickness column. Mirror of the §8 roof extractor
|
||||
# at `_roof_details_from_lines`.
|
||||
thickness_raw = self._local_val(lines, "Insulation Thickness")
|
||||
thickness_mm = self._parse_thickness_mm(thickness_raw)
|
||||
thickness_raw: Optional[str] = self._local_val(lines, "Insulation Thickness")
|
||||
thickness_mm: Optional[int] = self._parse_thickness_mm(thickness_raw)
|
||||
return FloorDetails(
|
||||
location=self._local_str(lines, "Location"),
|
||||
floor_type=self._local_str(lines, "Type"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue