Skip to content

Make Data.__dtype__ delegate to Data.__clstype__#1526

Open
daniel-locatelli wants to merge 2 commits into
compas-dev:mainfrom
daniel-locatelli:dtype-single-source
Open

Make Data.__dtype__ delegate to Data.__clstype__#1526
daniel-locatelli wants to merge 2 commits into
compas-dev:mainfrom
daniel-locatelli:dtype-single-source

Conversation

@daniel-locatelli

Copy link
Copy Markdown

What

Data.__dtype__ (property) and Data.__clstype__ (classmethod) computed the identical dtype string with two duplicated format expressions. This makes __clstype__ the single source of truth and lets the instance-level property delegate to it:

@property
def __dtype__(self):
    return self.__clstype__()

No behavior change — a classmethod accessed through an instance binds type(self), so subclasses resolve exactly as before.

Why it is safe for the plugin facades

Brep, NurbsCurve, and NurbsSurface override __dtype__ to pin the facade dtype (so backend instances like RhinoBrep / OCCBrep never leak compas_rhino/compas_occ into serialized files). Those overrides shadow the base property through the MRO, so the delegation in Data is never consulted for them. Verified on real backend instances in both Rhino 8 (ScriptEditor + Rhino.Inside: RhinoBrep, RhinoNurbsCurve) and OCC (conda pythonocc-core 7.9.3: OCCBrep, OCCNurbsCurve) — dtypes stay pinned and round-trips re-materialize the backend classes.

Verification

  • Full test suite (invoke test): green on Windows/CPython 3.12 (the two tests/compas/rpc tests pass once the venv has a compas_bootstrapper.py; see note below).
  • IronPython 2.7 suite (the ironpython.yml CI job replicated locally): 834 passed, 0 failed.
  • Headless Blender 4.2 (wheel installed into Blender''s Python): serialization + scene draw OK.
  • Downstream sweep with the patched wheel in isolated envs — no regressions in any of: compas_model, compas_fd, compas_timber (842 passed), compas_cadwork, compas_cgal, compas_libigl, compas_gmsh, compas_occ (22 passed), compas_fab (158 passed incl. pybullet backend), compas_robots, compas_rrc, compas_eve, compas_cloud, compas_ifc, compas_viewer, compas_notebook, compas_slicer, compas_fea2.

Notes

  • No user-facing change, so no CHANGELOG entry — happy to have the no changelog label applied (or to add an entry if preferred).
  • Unrelated observation from testing, in case useful: in a plain pip install -e dev venv on Windows, compas._os.select_python() resolves to the global interpreter (no compas_bootstrapper.py), which makes the RPC tests fail out of the box. Can open a separate issue if there is interest.

🤖 Generated with Claude Code

daniel-locatelli and others added 2 commits July 14, 2026 13:13
Both computed the identical dtype string with duplicated format
expressions. __clstype__ is now the single source of truth; the
instance-level property delegates to it (a classmethod accessed via
an instance binds type(self), so subclasses resolve correctly).
Facade classes (Brep, NurbsCurve, NurbsSurface) keep their own
__dtype__ overrides, which shadow the base property, so
backend-pinning behaviour is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant