Skip to content

BUG: Compare has_superclass in ITKClass equality check - #6953

Merged
dzenanz merged 1 commit into
InsightSoftwareConsortium:mainfrom
SID-6921:fix-itkclass-eq-missing-superclass
Oct 19, 2026
Merged

dzenanz merged 1 commit into
InsightSoftwareConsortium:mainfrom
SID-6921:fix-itkclass-eq-missing-superclass

Conversation

@SID-6921

Copy link
Copy Markdown
Contributor

Fix ITKClass.__eq__ to compare has_superclass, so stub-generation caching does not treat two classes that differ only in that field as equal.

Root cause

ITKClass.__init__ defines 10 fields, but __eq__ (duplicated in both
Wrapping/Generators/SwigInterface/igenerator.py and
Wrapping/Generators/Python/itk/pyi_generator.py) compared only 9,
omitting has_superclass. igenerator.py uses this equality to decide
whether to overwrite a cached .pkl file used for Python stub
generation, so a has_superclass-only change would leave a stale
pickle on disk.

AI assistance
  • Tool: Claude Code
  • Role: sibling-inconsistency review of the duplicated ITKClass
    definitions, comparing __init__'s field list against __eq__
    and the equivalent manual comparison in pyi_generator.py's
    merge().
  • Verified locally: isolated ITKClass from pyi_generator.py and
    confirmed two instances differing only in has_superclass
    compared equal before the fix, unequal after.

ITKClass.__eq__ omitted has_superclass, so two class
descriptions that differ only in that field compared equal.
The pyi stub generator uses this equality to decide whether a
cached pickle needs to be rewritten, so a has_superclass-only
change would leave a stale pickle in place.

Affects both copies of ITKClass (igenerator.py, pyi_generator.py).
@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances area:Python wrapping Python bindings for a class labels Oct 19, 2026
@hjmjohnson

Copy link
Copy Markdown
Member

@greptileai review this draft before I make it official

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds has_superclass to ITKClass.__eq__ in both generators.

  • ITKClass comparisons now include superclass status.

No actionable issues found. Review was based on code inspection; no tests were run.

Reviews (2) · Last reviewed commit: "BUG: Compare has_superclass in ITKClass ..." · Reviewed by Greptile

@hjmjohnson hjmjohnson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct. Thank you for tracking this down.

@hjmjohnson
hjmjohnson marked this pull request as ready for review October 19, 2026 12:49
@dzenanz
dzenanz merged commit 9df8f4c into InsightSoftwareConsortium:main Oct 19, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Python wrapping Python bindings for a class type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants