Skip to content

fix: remove duplicate W24PropertyHardnessRockwellScale definition#537

Merged
jmtts merged 2 commits into
mainfrom
claude/ecstatic-sagan-7jSOb
Jun 5, 2026
Merged

fix: remove duplicate W24PropertyHardnessRockwellScale definition#537
jmtts merged 2 commits into
mainfrom
claude/ecstatic-sagan-7jSOb

Conversation

@werk24

@werk24 werk24 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Problem

W24PropertyHardnessRockwellScale was defined twice in werk24/models/v1/property/hardness.py — once before W24PropertyHardnessRockwell and again after it, with byte-for-byte identical members.

Because of this:

  • The pydantic field W24PropertyHardnessRockwell.hardness_scale bound to the first class object (evaluated while the class body ran).
  • The module attribute werk24.models.v1.property.hardness.W24PropertyHardnessRockwellScale — what pickle resolves by qualified name — pointed at the second.

So a parsed/constructed W24PropertyHardnessRockwell held an enum member whose class could not be found under its own name, and pickling it (e.g. across a ProcessPoolExecutor, cache, or Celery boundary) raised:

PicklingError: Can't pickle <enum 'W24PropertyHardnessRockwellScale'>: it's not the same object as werk24.models.v1.property.hardness.W24PropertyHardnessRockwellScale

This surfaced as a production error in the core-reader service (Sentry CORE-READER-13Z) when grammar parses run in worker processes return Rockwell hardness results.

Fix

Collapse the two definitions into a single one placed above W24PropertyHardnessRockwell (keeping the version with the """List of available Rockwell hardness scales.""" docstring) and delete the second block. Members are byte-for-byte identical, so this is behavior-preserving — it only removes the shadowing redefinition.

I also grepped the whole werk24 package for any other accidental same-file class/enum redefinitions; this was the only one. (W24PropertyGlasHomogeneity vs W24PropertyGlassHomogeneity in glass_homogeneity.py differ by spelling and are distinct classes.)

Verification

  • python -m py_compile werk24/models/v1/property/hardness.py
  • Identity check: W24PropertyHardnessRockwell.model_fields["hardness_scale"].annotation is W24PropertyHardnessRockwellScale → now True (was False) ✅
  • Round-trip pickle of a constructed W24PropertyHardnessRockwell succeeds (previously raised PicklingError) ✅
  • Test suite: 155 passed, 4 skipped. The only failures are pre-existing InvalidLicenseException integration tests that require a live API license/token (unrelated to this change). ✅

Once this ships and core-reader bumps the dependency, the temporary shim there becomes a no-op.

https://claude.ai/code/session_01McoehiPCbG2oVA4WukFo3Z


Generated by Claude Code

claude added 2 commits June 5, 2026 09:06
The enum was defined twice in hardness.py; the pydantic field bound to the
first class object while the module exported the second, so constructed
W24PropertyHardnessRockwell instances failed to pickle ("not the same object
as ...W24PropertyHardnessRockwellScale"). Collapse to a single definition
above W24PropertyHardnessRockwell. Behavior-preserving — members are identical.

https://claude.ai/code/session_01McoehiPCbG2oVA4WukFo3Z
Release the duplicate W24PropertyHardnessRockwellScale pickling fix.

https://claude.ai/code/session_01McoehiPCbG2oVA4WukFo3Z
@jmtts jmtts merged commit c72d9ad into main Jun 5, 2026
7 checks passed
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.

3 participants