Skip to content

Commit 1060430

Browse files
committed
fix(format): Format all - isort, black, ruff
- Update all files to format properly. - Fix ruff linting errors
1 parent 43e9ff0 commit 1060430

173 files changed

Lines changed: 16575 additions & 16855 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PHX/PHPP/phpp_app.py

Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# -*- coding: utf-8 -*-
21
# -*- Python Version: 3.10 -*-
32

43
"""Controller for managing the PHPP Connection."""
54

6-
from typing import Dict, List
75

86
from PHX.model import building, certification, components, project
97
from PHX.model.hvac.collection import NoDeviceFoundError
@@ -146,7 +144,7 @@ def get_phpp_version(
146144
"1-PE-FACTORS": "EN",
147145
}
148146
language = None
149-
for search_string in language_search_data.keys():
147+
for search_string in language_search_data:
150148
if search_string in str(data[-1]).upper().strip():
151149
language = language_search_data[search_string]
152150
language = language.strip().replace(" ", "_").replace(".", "_")
@@ -163,17 +161,11 @@ def get_phpp_version(
163161
def is_easyPh(self) -> bool:
164162
"""Return True if the active PHPP file is an 'easyPH' file."""
165163
name = self.shape.EASY_PH.name.upper()
166-
if name in self.xl.get_upper_case_worksheet_names():
167-
print("PHPP is easyPH")
168-
return True
169-
else:
170-
return False
164+
return name in self.xl.get_upper_case_worksheet_names()
171165

172166
def phpp_version_equals_phx_phi_cert_version(self, _phx_variant: project.PhxVariant) -> bool:
173167
"""Return True if the PHX PHI Certification Version and the PHPP Version match."""
174-
if not int(_phx_variant.phi_certification_major_version) == int(self.version.number_major):
175-
return False
176-
return True
168+
return int(_phx_variant.phi_certification_major_version) == int(self.version.number_major)
177169

178170
def write_certification_config(self, phx_project: project.PhxProject) -> None:
179171
if self.easyPh:
@@ -309,7 +301,7 @@ def write_climate_data(self, phx_project: project.PhxProject) -> None:
309301
def write_project_constructions(self, phx_project: project.PhxProject) -> None:
310302
"""Write all of the opaque constructions to the PHPP 'U-Values' worksheet."""
311303

312-
construction_blocks: List[uvalues_constructor.ConstructorBlock] = []
304+
construction_blocks: list[uvalues_constructor.ConstructorBlock] = []
313305
for phx_construction in phx_project.assembly_types.values():
314306
construction_blocks.append(
315307
uvalues_constructor.ConstructorBlock(shape=self.shape.UVALUES, phx_construction=phx_construction)
@@ -321,8 +313,8 @@ def write_project_constructions(self, phx_project: project.PhxProject) -> None:
321313
def write_project_window_components(self, phx_project: project.PhxProject) -> None:
322314
"""Write all of the frame and glass constructions from a PhxProject to the PHPP 'Components' worksheet."""
323315

324-
glazing_component_rows: List[component_glazing.GlazingRow] = []
325-
frame_component_rows: List[component_frame.FrameRow] = []
316+
glazing_component_rows: list[component_glazing.GlazingRow] = []
317+
frame_component_rows: list[component_frame.FrameRow] = []
326318
for phx_construction in phx_project.window_types.values():
327319
glazing_component_rows.append(
328320
component_glazing.GlazingRow(shape=self.shape.COMPONENTS, phx_construction=phx_construction)
@@ -337,7 +329,7 @@ def write_project_window_components(self, phx_project: project.PhxProject) -> No
337329
def write_project_ventilation_components(self, phx_project: project.PhxProject) -> None:
338330
"""Write all of the ventilators from a PhxProject to the PHPP 'Components' worksheet."""
339331

340-
phpp_ventilator_rows: List[component_vent.VentilatorRow] = []
332+
phpp_ventilator_rows: list[component_vent.VentilatorRow] = []
341333
for phx_variant in phx_project.variants:
342334
for mech_collection in phx_variant.mech_collections:
343335
for phx_ventilator in mech_collection.ventilation_devices:
@@ -365,7 +357,7 @@ def write_project_tfa(self, phx_project: project.PhxProject) -> None:
365357
def write_project_opaque_surfaces(self, phx_project: project.PhxProject) -> None:
366358
"""Write all of the opaque surfaces from a PhxProject to the PHPP 'Areas' worksheet."""
367359

368-
surfaces: List[areas_surface.SurfaceRow] = []
360+
surfaces: list[areas_surface.SurfaceRow] = []
369361
for phx_variant in phx_project.variants:
370362
for opaque_component in phx_variant.building.opaque_components:
371363
for phx_polygon in opaque_component.polygons:
@@ -382,11 +374,7 @@ def write_project_opaque_surfaces(self, phx_project: project.PhxProject) -> None
382374
)
383375

384376
if len(surfaces) >= 100:
385-
print(
386-
f"Warning: {len(surfaces)} surfaces found in the model. Ensure that you have "
387-
"added enough rows to the 'Areas' worksheet to handle that many surfaces. "
388-
"By default the PHPP can only have 100 surfaces input."
389-
)
377+
pass
390378

391379
phpp_surfaces_rows_sorted = sorted(surfaces, key=lambda x: x.phx_polygon.display_name.lower())
392380
self.areas.write_surfaces(phpp_surfaces_rows_sorted)
@@ -395,18 +383,14 @@ def write_project_opaque_surfaces(self, phx_project: project.PhxProject) -> None
395383
def write_project_thermal_bridges(self, phx_project: project.PhxProject) -> None:
396384
"""Write all of the thermal-bridge elements of a PhxProject to the PHPP 'Areas' worksheet."""
397385

398-
thermal_bridges: List[areas_thermal_bridges.ThermalBridgeRow] = []
386+
thermal_bridges: list[areas_thermal_bridges.ThermalBridgeRow] = []
399387
for variant in phx_project.variants:
400388
for zone in variant.zones:
401389
for phx_tb in zone.thermal_bridges:
402390
thermal_bridges.append(areas_thermal_bridges.ThermalBridgeRow(self.shape.AREAS, phx_tb))
403391

404392
if len(thermal_bridges) >= 100:
405-
print(
406-
f"Warning: {len(thermal_bridges)} thermal bridges found in the model. Ensure that you have "
407-
"added enough rows to the 'Areas' worksheet to handle that many thermal bridges. "
408-
"By default the PHPP can only have 100 thermal bridges input."
409-
)
393+
pass
410394

411395
self.areas.write_thermal_bridges(thermal_bridges)
412396
return None
@@ -428,7 +412,7 @@ def write_project_window_surfaces(self, phx_project: project.PhxProject) -> None
428412
window_type_phpp_ids = self.variants.get_window_type_phpp_ids()
429413

430414
# -- Write in the window-data
431-
phpp_windows: List[windows_rows.WindowRow] = []
415+
phpp_windows: list[windows_rows.WindowRow] = []
432416
for phx_variant in phx_project.variants:
433417
for phx_component in phx_variant.building.opaque_components:
434418
for phx_aperture in phx_component.apertures:
@@ -460,19 +444,15 @@ def write_project_window_surfaces(self, phx_project: project.PhxProject) -> None
460444
)
461445

462446
if len(phpp_windows) >= 150:
463-
print(
464-
f"Warning: {len(phpp_windows)} windows found in the model. Ensure that you have "
465-
"added enough rows to the 'Windows' worksheet to handle that many windows. "
466-
"By default the PHPP can only have 150 windows input."
467-
)
447+
pass
468448

469449
phpp_windows_rows_sorted = sorted(phpp_windows, key=lambda x: x.phx_polygon.display_name.lower())
470450
self.windows.write_windows(phpp_windows_rows_sorted)
471451
return None
472452

473453
def write_project_window_shading(self, phx_project: project.PhxProject) -> None:
474454
def _get_ap_element_from_dict(
475-
_window_name: str, _dict: Dict[str, components.PhxApertureElement]
455+
_window_name: str, _dict: dict[str, components.PhxApertureElement]
476456
) -> components.PhxApertureElement:
477457
"""When reading from excel, it MIGHT come in as a float. This means
478458
that any windows with a numerical name (ie: '106', '205', etc) will get
@@ -499,7 +479,7 @@ def _get_ap_element_from_dict(
499479
window_names = self.windows.get_all_window_names()
500480

501481
# Get all the PHX Aperture objects
502-
phx_aperture_dict: Dict[str, components.PhxApertureElement] = {}
482+
phx_aperture_dict: dict[str, components.PhxApertureElement] = {}
503483
for phx_variant in phx_project.variants:
504484
for phx_component in phx_variant.building.opaque_components:
505485
for phx_aperture in phx_component.apertures:
@@ -512,7 +492,7 @@ def _get_ap_element_from_dict(
512492
)
513493

514494
# Write out all the data to the Shading Worksheet
515-
phpp_shading_rows: List[shading_rows.ShadingRow] = []
495+
phpp_shading_rows: list[shading_rows.ShadingRow] = []
516496
for phx_aperture_element in phx_aperture_elements_in_order:
517497
phpp_shading_rows.append(
518498
shading_rows.ShadingRow(
@@ -534,7 +514,7 @@ def write_project_ventilators(self, phx_project: project.PhxProject) -> None:
534514
if self.easyPh:
535515
return None
536516

537-
phpp_vent_unit_rows: List[vent_units.VentUnitRow] = []
517+
phpp_vent_unit_rows: list[vent_units.VentUnitRow] = []
538518
for phx_variant in phx_project.variants:
539519
for mech_collection in phx_variant.mech_collections:
540520
for phx_ventilator in mech_collection.ventilation_devices:
@@ -556,7 +536,7 @@ def write_project_spaces(self, phx_project: project.PhxProject) -> None:
556536
if self.easyPh:
557537
return None
558538

559-
phpp_vent_rooms: List[vent_space.VentSpaceRow] = []
539+
phpp_vent_rooms: list[vent_space.VentSpaceRow] = []
560540
for phx_variant in phx_project.variants:
561541
for zone in phx_variant.building.zones:
562542
for room in zone.spaces:
@@ -586,11 +566,7 @@ def write_project_spaces(self, phx_project: project.PhxProject) -> None:
586566
phpp_vent_rooms.append(phpp_rm)
587567

588568
if len(phpp_vent_rooms) >= 30:
589-
print(
590-
f"Warning: {len(phpp_vent_rooms)} spaces found in the model. Ensure that you have "
591-
"added enough rows to the 'Additional Vent' worksheet to handle that many spaces. "
592-
"By default the PHPP can only have 30 spaces input."
593-
)
569+
pass
594570

595571
self.addnl_vent.write_spaces(phpp_vent_rooms)
596572
return None
@@ -600,7 +576,7 @@ def write_project_ventilation_type(self, phx_project: project.PhxProject) -> Non
600576
if self.easyPh:
601577
return None
602578

603-
for variant in phx_project.variants:
579+
for _variant in phx_project.variants:
604580
self.ventilation.write_ventilation_type(
605581
# TODO: Get the actual type from the model someplace?
606582
# TODO: How to combine Variants?
@@ -664,11 +640,7 @@ def write_project_hot_water(self, phx_project: project.PhxProject) -> None:
664640
# -- Tanks
665641
# Use only the first 2 tanks for PHPP
666642
if len(mech_collection.dhw_tank_devices) > 2:
667-
print(
668-
f"Warning: PHPP only allows 2 tanks."
669-
f"{len(mech_collection.dhw_tank_devices)} tank"
670-
f'found in the Variant "{variant.name}"'
671-
)
643+
pass
672644

673645
tank_inputs = []
674646
for i, phx_dhw_tank in enumerate(mech_collection.dhw_tank_devices[:2], start=1):
@@ -685,12 +657,7 @@ def write_project_hot_water(self, phx_project: project.PhxProject) -> None:
685657
branch_piping_inputs = []
686658
branch_pipe_groups = mech_collection.dhw_distribution_piping_segments_by_diam
687659
if len(branch_pipe_groups) > 5:
688-
print(
689-
"Warning: PHPP only allows 5 groups of DHW branch piping. "
690-
f"{len(branch_pipe_groups)} piping groups "
691-
f'found in the Variant "{variant.name}". '
692-
"Using only then first 5 piping groups."
693-
)
660+
pass
694661

695662
for i, phx_branch_piping in enumerate(branch_pipe_groups[:5]):
696663
branch_piping_inputs.append(
@@ -707,12 +674,7 @@ def write_project_hot_water(self, phx_project: project.PhxProject) -> None:
707674
recirc_piping_inputs = []
708675
recirc_pipe_groups = mech_collection.dhw_recirc_piping_segments_by_diam
709676
if len(recirc_pipe_groups) > 5:
710-
print(
711-
"Warning: PHPP only allows 5 groups of DHW Recirc. piping. "
712-
f"{len(recirc_pipe_groups)} piping groups "
713-
f'found in the Variant "{variant.name}". '
714-
"Using only then first 5 piping groups."
715-
)
677+
pass
716678

717679
for i, phx_recirc_piping in enumerate(recirc_pipe_groups[:5]):
718680
recirc_piping_inputs.append(
@@ -772,10 +734,6 @@ def activate_variant_assemblies(self) -> None:
772734
# -- and add each one to the Variants assembly-layers section
773735
for i, assembly_name in enumerate(self.u_values.get_used_constructor_names(), start=0):
774736
if i > 25:
775-
print(
776-
"WARNING: The Variants worksheet can only handle 26 different assemblies."
777-
"You will have to set up the assembly-layer Variants links manually."
778-
)
779737
continue
780738
self.variants.write_assembly_layer(assembly_name, i)
781739

PHX/PHPP/phpp_localization/load.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# -*- Python Version: 3.10 -*-
32

43
"""Functions for finding / loading the right PHPP-ShapeFile."""

PHX/PHPP/phpp_localization/shape_model.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
# -*- coding: utf-8 -*-
21
# -*- Python Version: 3.10 -*-
32

43
"""Data model of the PHPP 'Shape' (worksheet names and input column names)."""
54

6-
from typing import Dict, Optional
75

86
from pydantic import BaseModel
97

108
# -----------------------------------------------------------------------------
119

1210

1311
class InputItem(BaseModel):
14-
column: Optional[str] = None
15-
row: Optional[int] = None
16-
unit: Optional[str] = None
12+
column: str | None = None
13+
row: int | None = None
14+
unit: str | None = None
1715

1816
@property
1917
def xl_range(self) -> str:
@@ -28,8 +26,8 @@ class VerificationInputItem(BaseModel):
2826
locator_string: str
2927
input_column: str
3028
input_row_offset: int
31-
options: Optional[Dict] = None
32-
unit: Optional[str] = None
29+
options: dict | None = None
30+
unit: str | None = None
3331

3432

3533
class Verification(BaseModel):
@@ -515,7 +513,7 @@ class VentilationInputItem(BaseModel):
515513
locator_col: str
516514
locator_string: str
517515
input_column: str
518-
unit: Optional[str] = None
516+
unit: str | None = None
519517

520518

521519
class Ventilation(BaseModel):
@@ -776,7 +774,7 @@ class DhwBranchPiping(BaseModel):
776774

777775

778776
class DhwTankInputOptions(BaseModel):
779-
options: Dict
777+
options: dict
780778

781779

782780
class DhwTankInputColumns(BaseModel):
@@ -875,7 +873,7 @@ class ElectricityInputColumns(BaseModel):
875873
class ElectricityInputRow(BaseModel):
876874
data: int
877875
selection: int
878-
selection_options: Dict
876+
selection_options: dict
879877

880878

881879
class ElectricityInputRows(BaseModel):
@@ -995,7 +993,7 @@ class PerAddresses(BaseModel):
995993
class PerDataBlock(BaseModel):
996994
locator_string_heading: str
997995
locator_string_start: str
998-
locator_string_end: Optional[str] = None
996+
locator_string_end: str | None = None
999997

1000998

1001999
class PerNamedRanges(BaseModel):
@@ -1048,7 +1046,7 @@ class DataVersion(BaseModel):
10481046
locator_string_header: str
10491047
locator_col_entry: str
10501048
locator_string_entry: str
1051-
input_column: Dict
1049+
input_column: dict
10521050

10531051

10541052
class Data(BaseModel):

PHX/PHPP/phpp_model/areas_data.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# -*- coding: utf-8 -*-
21
# -*- Python Version: 3.10 -*-
32

43
"""Model class for the Ventilation worksheet various input items."""
54

65
from __future__ import annotations
76

87
from dataclasses import dataclass
9-
from typing import Optional
108

119
from PHX.PHPP.phpp_localization import shape_model
1210
from PHX.xl import xl_data
@@ -20,8 +18,8 @@ class AreasInput:
2018
shape: shape_model.Areas
2119
input_type: str
2220
input_data: xl_writable
23-
input_unit: Optional[str] = None
24-
target_unit: Optional[str] = None
21+
input_unit: str | None = None
22+
target_unit: str | None = None
2523

2624
def create_xl_item(self, _sheet_name: str, _row_num: int) -> xl_data.XlItem:
2725
"""Returns a list of the XL Items to write for this Data item

0 commit comments

Comments
 (0)