mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 06:28:36 +00:00
Fix all ty diagnostics on ifcviewer-wgpu (ci-lint ty-ios + ty-bonsai)
This branch carried v0.8.0's strict `[tool.ty.rules] all = "error"` config but not the source fixes that were made upstream to satisfy it, so both ci-lint ty gates were failing: `poe ty-ios` reported 256 diagnostics and `poe ty-bonsai` 258. Both are now clean. Most fixes are ported from v0.8.0 and follow two idioms: initialise a name before a conditional that may not bind it (plus an `assert` where the invariant is real but not provable), and close an exhaustive `if`/`elif` chain with `else: assert False, <discriminant>`. The branch's own newer accessors are preserved throughout - `.file`, `.declaration`, `file.types()`, `get_max_id()` are kept rather than reverted to `wrapped_data.*`, and non-ty upstream changes (notably the in-progress geometry cache removal) are deliberately not pulled in. Notable fixes that are not straight ports: * ifcopenshell_wrapper.pyi: `entity_instance.file` was declared as `def file(self) -> file`, where the property name shadows the `class file` below it, so the annotation resolved to `Unknown`. Every `element.file` in the codebase was therefore unchecked. Qualifying it to `ifcopenshell.file` restores `.schema` to its Literal union and surfaces no new diagnostics. * model/wall.py: a duplicated merge fragment in the void-straddle path ran an always-true `if void_straddles:` that read `new_opening` from the mutually exclusive branch (stale value, or NameError on the first iteration), followed by an unreachable duplicate `elif`. Removing it makes the file match v0.8.0. * light/operator.py: upstream's own fix unpacks three targets from two values and raises ValueError unconditionally; corrected to `None, None, None`. * assign_system.py, validate.py, geom/main.py: walrus-in-genexp is valid at runtime (PEP 572 binds in the containing scope) but ty does not model it; rewritten as explicit loops, matching upstream. Verified: poe ty-ios, poe ty-bonsai, ruff check src/ nix/, black --check ., and compileall -W error at py3.10 (ifcopenshell-python) and py3.11 (bonsai). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -216,6 +216,7 @@ def update_translations_from_po(po_directory: Path, translations_module: Path):
|
||||
|
||||
|
||||
if BPY_IS_LOADED:
|
||||
import bpy
|
||||
|
||||
class SetupTranslationUI(bpy.types.Operator):
|
||||
bl_idname = "bim.setup_translation_ui"
|
||||
|
||||
@@ -82,6 +82,7 @@ class Generator:
|
||||
}
|
||||
""".replace("{entity}", location.split("#")[-1]))
|
||||
# filter parents for the brick entity
|
||||
parent = None
|
||||
for row in query:
|
||||
parent = row.get("parent").toPython()
|
||||
if "brickschema.org" in parent and parent in references.keys():
|
||||
|
||||
@@ -1036,6 +1036,7 @@ class LibraryGenerator:
|
||||
seat_width_offset = 0.7 * width / 2 if cistern_depth else width / 2
|
||||
seat_start_width_offset = 0.6 * width
|
||||
|
||||
cistern_3d = None
|
||||
if cistern_height:
|
||||
cistern = builder.rectangle(size=V(width, cistern_depth), position=shift_to_center)
|
||||
cistern_3d = ifcopenshell.util.element.copy_deep(self.file, cistern)
|
||||
@@ -1118,6 +1119,7 @@ class LibraryGenerator:
|
||||
|
||||
# cistern
|
||||
if cistern_height:
|
||||
assert cistern_3d
|
||||
cistern_3d = builder.extrude(
|
||||
cistern_3d, cistern_height + seat_level / 2, position=V(0, 0, seat_level / 2)
|
||||
)
|
||||
|
||||
@@ -143,6 +143,7 @@ class LibraryGenerator:
|
||||
if "unused" in ifc_params:
|
||||
del ifc_params["unused"]
|
||||
|
||||
profiles_gap = ...
|
||||
if prof_type == "profile_hollow*_square":
|
||||
ifc_params["YDim"] = ifc_params["XDim"]
|
||||
elif ifc_profile_name == "IfcCircleHollowProfileDef":
|
||||
@@ -160,6 +161,7 @@ class LibraryGenerator:
|
||||
profile = self.file.create_entity(ifc_profile_name, ProfileName=prof_name, ProfileType="AREA", **ifc_params)
|
||||
|
||||
if prof_type == "profile_l*lbeam_2l":
|
||||
assert profiles_gap is not ...
|
||||
profile.ProfileName = None # to avoid name confusion
|
||||
mode = "SLBB" if prof_name.endswith("_SLBB") else "LLBB"
|
||||
profile = self.create_double_l_profile(profile, prof_name, profiles_gap, mode)
|
||||
|
||||
Reference in New Issue
Block a user