-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add a few more tests for mypyc_attr native_class (dunder methods and metaclasses) #18999
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
base: master
Are you sure you want to change the base?
Conversation
Testing dunder methods and metaclasses
a86ea9e
to
7df6ab1
Compare
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions. Can you also check the build failures?
pass | ||
|
||
@mypyc_attr(native_class=True) | ||
class A(metaclass=M): # E: Class is marked as native_class=True but it can't be a native class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also mention in the error message that the metaclass is not supported with a native class?
f = native.Foo() | ||
assert(hasattr(f, 'bar')) | ||
assert(f.bar == 'start') | ||
f.bar = 'test' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we test that the __set__
method is called, and this doesn't just replace the descriptor? A hacky way would be to set some global flag the __set__
is called.
assert(hasattr(f, 'bar')) | ||
assert(f.bar == 'start') | ||
f.bar = 'test' | ||
assert(f.bar == 'test') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly here it would be good to ensure that __get__
(and __delete__
below) actually get called.
No description provided.