KEMBAR78
[mypyc] Support for annotating classes to be native or not (native_class=True/False) by svalentin · Pull Request #18802 · python/mypy · GitHub
Skip to content

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