Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mypyc] Support for annotating classes to be native or not (native_class=True/False) #18802

Merged
merged 5 commits into from
Mar 28, 2025

Conversation

svalentin
Copy link
Collaborator

No description provided.

@svalentin svalentin force-pushed the non-extension-class branch from 1928a52 to 908c537 Compare March 14, 2025 22:36
@svalentin
Copy link
Collaborator Author

Doing setattr(ExtensionClass, 'attr_class', 5) does seem to work though.

@svalentin svalentin requested a review from JukkaL March 14, 2025 23:22
@cdce8p cdce8p added the topic-mypyc mypyc bugs label Mar 16, 2025
@svalentin svalentin changed the title [mypyc] Initial support for annotating classes to be non extension [mypyc] Initial support for annotating classes to be native or not (native_class=True/False) Mar 28, 2025
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! Just one idea about a test case.


@mypyc_attr(native_class=True)
@decorator
class NonNativeClassContradiction(): # E: Class is marked as native_class=True but it can't be a native class
Copy link
Collaborator

Choose a reason for hiding this comment

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

Test also a successful case of using native_class=True (in a run test so that the runtime behavior can be tested).

@svalentin svalentin changed the title [mypyc] Initial support for annotating classes to be native or not (native_class=True/False) [mypyc] Support for annotating classes to be native or not (native_class=True/False) Mar 28, 2025
@svalentin svalentin merged commit 98e3faf into python:master Mar 28, 2025
12 checks passed
@svalentin svalentin deleted the non-extension-class branch March 28, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-mypyc mypyc bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants