Repository navigation
Fix qualified names for lambdas in class headers - #112
Merged
alexmojaki merged 1 commit intoOct 29, 2026
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the class-header qualified-name fix.
No open issues 🎉
What changed in this PR
Fixes Source.code_qualname() so lambdas in class headers use the enclosing scope rather than incorrectly including the class being defined.
Changes:
- Visits class decorators, bases, and keywords outside the class scope while preserving class-body and type-parameter handling.
- Adds regression coverage across module, function, and nested-class scopes, plus Python 3.12+ generic class headers.
| File | Description |
|---|---|
tests/test_qualname_class_headers.py |
Compares reported qualified names with runtime __qualname__ values and checks existing behavior. |
executing/executing.py |
Separates class-header traversal from class-scope traversal. |
Review effort: Balanced
Owner
|
Thanks! |
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.
Source.code_qualname()currently adds the class being defined to lambdas in class decorators, base expressions and metaclass keywords. For example, a module-level@lambda cls: clsreportsDecorated.<lambda>instead of the function's actual<lambda>name.Visit those header expressions in the enclosing scope while retaining the existing handling of class bodies, function headers and type parameters. The regressions compare reported names with actual
func.__qualname__values at module, function and nested-class scope, including Python 3.12+ generic class headers.Validation on Python 3.13.1:
EXECUTING_SLOW_TESTS=1: 254 passed, 6 existing skips.