Skip to content

Fix qualifier leak on repeated assignment in ApplyTypeAnnotationsVisitor - #1480

Open
watercrossing wants to merge 1 commit into
Instagram:mainfrom
watercrossing:fix-qualifier-leak-repeated-assignment
Open

watercrossing wants to merge 1 commit into
Instagram:mainfrom
watercrossing:fix-qualifier-leak-repeated-assignment

Conversation

@watercrossing

Copy link
Copy Markdown

Summary

_annotate_single_target did not pop the target name from self.qualifier when the name had already been annotated (the second assignment, the branch added in #956), so all later definitions in the module were looked up under the wrong qualified name and left unannotated. This pops it before the already_annotated check, so every path pops it.

Fixes #1479.

Test Plan

Added toplevel_then_function and class_then_method_and_function to test_no_duplicate_annotations; both fail before the change and pass after it. All 95 tests in test_apply_type_annotations.py pass.

_annotate_single_target did not pop the target name from self.qualifier
when the name had already been annotated (the second assignment, added
in Instagram#956), so all later definitions in the module were looked up under
the wrong qualified name and left unannotated. Pop it before the
already_annotated check.

Fixes Instagram#1479
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApplyTypeAnnotationsVisitor: a repeated assignment leaves its name on the qualifier stack, so every later definition loses its annotations

1 participant