Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
svalentin merged 5 commits into
python:masterfrom
svalentin:non-extension-class
Mar 28, 2025
Merged

[mypyc] Support for annotating classes to be native or not (native_class=True/False)#18802
svalentin merged 5 commits into
python:masterfrom
svalentin:non-extension-class

Conversation

@svalentin

Copy link
Copy Markdown
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
Copy Markdown
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

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
@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