From 821a0a08f7508a72c1d71fb8cfc46963d3f60b39 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 28 Apr 2026 12:02:34 +0000 Subject: [PATCH] addressing feedback on from_api_response --- datatypes/epc/domain/mapper.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/datatypes/epc/domain/mapper.py b/datatypes/epc/domain/mapper.py index 7ef74340..d5212fe5 100644 --- a/datatypes/epc/domain/mapper.py +++ b/datatypes/epc/domain/mapper.py @@ -1,5 +1,5 @@ from datetime import date -from typing import List, Optional, Sequence, Union +from typing import List, Optional, Sequence, Union, Dict, Any from datatypes.epc.domain.epc_property_data import ( EnergyElement, @@ -1448,7 +1448,7 @@ class EpcPropertyDataMapper: return [EpcPropertyDataMapper._map_energy_element(e) for e in elements] @staticmethod - def from_api_response(data: dict) -> "EpcPropertyData": + def from_api_response(data: Dict[str, Any]) -> "EpcPropertyData": """ Dispatch to the correct schema mapper based on schema_type. Supports RdSAP-Schema-21.0.0 and RdSAP-Schema-21.0.1 only. @@ -1459,11 +1459,13 @@ class EpcPropertyDataMapper: schema = data.get("schema_type", "") if schema == "RdSAP-Schema-21.0.1": from datatypes.epc.schema.rdsap_schema_21_0_1 import RdSapSchema21_0_1 + return EpcPropertyDataMapper.from_rdsap_schema_21_0_1( from_dict(RdSapSchema21_0_1, data) ) if schema == "RdSAP-Schema-21.0.0": from datatypes.epc.schema.rdsap_schema_21_0_0 import RdSapSchema21_0_0 + return EpcPropertyDataMapper.from_rdsap_schema_21_0_0( from_dict(RdSapSchema21_0_0, data) ) @@ -1596,7 +1598,11 @@ def _map_sap_heating( fuel_type = ( _raw_fuel if _raw_fuel - else ("Electricity" if main.system_type.lower() in _ELECTRIC_SYSTEM_TYPES else _raw_fuel) + else ( + "Electricity" + if main.system_type.lower() in _ELECTRIC_SYSTEM_TYPES + else _raw_fuel + ) ) return SapHeating( @@ -1618,7 +1624,11 @@ def _map_sap_heating( secondary_fuel_type=secondary_fuel_type, secondary_heating_type=heating.secondary_heating.secondary_system, shower_outlets=shower_outlets, - cylinder_size=heating.water_heating.cylinder_size if heating.water_heating.cylinder_size != "No Cylinder" else None, + cylinder_size=( + heating.water_heating.cylinder_size + if heating.water_heating.cylinder_size != "No Cylinder" + else None + ), cylinder_insulation_type=heating.water_heating.insulation_type, cylinder_insulation_thickness_mm=heating.water_heating.insulation_thickness_mm, immersion_heating_type=heating.water_heating.immersion_type,