Forward class keyword arguments in mypyc - #21962
Open
MarthalaJagruthiReddy wants to merge 4 commits into
Open
Conversation
Fixes python#21938 by forwarding class-definition keywords to __init_subclass__ for native classes and to the metaclass for non-native classes. Adds regression coverage for both compiler paths.
Update the runtime declaration and C implementation so native classes can forward keyword arguments to __init_subclass__.
Expose the kwargs dictionary as an argument to the native __init_subclass__ operation.
Cover native and non-native class keyword forwarding and update the corresponding IR expectations.
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.
Fixes #21938
Class-definition keyword arguments were preserved in mypy's AST but silently dropped by mypyc. This change forwards them through the native and non-native class-generation paths.
Specifically:
__init_subclass__for native extension classesmetaclass=because Python consumes it for metaclass selection__prepare__and the class bodyTests:
I used an AI coding assistant to help investigate the issue and draft the implementation; I reviewed the resulting code and test behavior locally.