Repository navigation
Normalize annotation-independent method headers in ClassBodyNormalForm - #646
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On the 540-file
comms-tui(src/toad) scan,SiblingOverrideDetectorreturned 0 findings andRestatedOverrideDetectorreturned 0 findings — missing identical@propertyand concrete method overrides across Qt and Textual siblings (ConversationPager.selected_categories,QuestionContext.question,SnapshotPresentation.commit_claim,BlockCursor.move,Page.shown,FrozenClosedHistory.latest, etc.).Root cause at
nominal_refactor_advisor/class_index.py:4759:ClassBodyNormalForm._normalized_methodstripped leading docstrings and receiver type-narrowing aliases, but left parameter and return annotations in the normalized AST and free-name bindings. Two identical concrete methods where one omitted-> ...(QtConversationHistory.selected_categories) and the other declared-> frozenset[type[MessageCategory]](ConversationHistory.selected_categories), or where each annotated its own class (-> QtQuestionvs-> Question), hashed to different digests and failedsame_declaration_as.Fix
ClassBodyNormalForm._strip_method_header_annotations(nominal_refactor_advisor/class_index.py:4779): shallow-copy method parameters and clear parameter/return annotations when every decorator on the method is annotation-independent (property,cached_property,classmethod,staticmethod,override,final, or none).@abstractmethod,@overload, and custom/unmodeled decorators keep their signatures intact so contract widenings likeActivatesContract.activate() -> NonevsActivates.activate() -> objectare never conflated.SiblingOverrideMove.select_lifted_index(nominal_refactor_advisor/refactors/sibling_overrides.py:828): when lifting siblings that differ only by omitted annotations, prefer the most-annotated sibling whose annotation imports move cleanly without closing a cycle (soConversationPager.selected_categoriespreserves-> frozenset[type[MessageCategory]]). When siblings declare conflicting annotations on the same header slot (-> QtQuestionvs-> Question), refuse blind lifting withNeededInput.SOURCE_CHANGE.RestatedOverrideDeletion._require_inherited_preserves_annotations(nominal_refactor_advisor/refactors/restated_overrides.py:944): allow deleting an unannotated or matching-annotation override automatically, while refusing to silently drop annotations that the subclass declares and the inherited method lacks (FrozenClosedHistory.latestover unannotatedClosedHistory.latest).Live Toad Impact (
src/toad, 540 files)SiblingOverrideDetector:0 -> 13real findings (includingConversationPager.selected_categoriesasexecutable_candidatelifting cleanly with-> frozenset[type[MessageCategory]]preserved, andQtQuestion/QuestionQuestionContext.question).RestatedOverrideDetector:0 -> 1real finding (FrozenClosedHistory.latest), withActivates.activate(@abstractmethod) cleanly excluded.Proof
tests/test_sibling_overrides.pyandtests/test_restated_overrides.py.REL_IMPORTS=0.