-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Remove @builtinclass #2294
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
Remove @builtinclass #2294
Conversation
Maybe @JukkaL can chime in here, but it seems to me that inheriting from object isn't the same as being a builtin class? |
@ddfisher you mean "being |
Ah, yep -- I misread that. It looks to me like we don't currently use the |
I guess either can be done in a separate PR. |
The nearest_builtin_ancestor() is actually used in a check for instance layout conflicts. This is currently a no-op because only |
The class in the test inherits from function to avoid warnings about compatibility of __add__
import typing | ||
class A(int, str): pass # E: Instance layout conflict in multiple inheritance | ||
class A(int, function): pass # E: Instance layout conflict in multiple inheritance |
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.
str
and int
have conflicting definition of __add__
, and this test is not about that.
Added check for "builtin.lower-case" since it covers many cases. Are there exceptions to this rule? Turns out there were tests for this feature, but they were skipped. |
That's a bizarre solution. Please roll that back so that it behaves exactly as before and file a separate bug. The issue is way more complicated than that -- every extension module may define "builtin" types (according to this definition). |
I will roll back, but I don't understand the problem. Can you elaborate - what's the ultimate intended behavior?
What's wrong with option 3 ? |
Option 3 is not at all how Python actually works. Adding stuff to the When there is a layout conflict due to attempting to M.I. from two different extension classes, Python will reject the class definition at runtime, so mypy won't be finding new problems even if it did faithfully emulate the runtime behavior. But the runtime behavior is also impossible to emulate (it requires more information that can be expressed using PEP 484 and the We should get rid of the builtinclass decorator from typeshed (there are no uses currently) and of the code in mypy related to So mypy should just not bother trying to detect layout conflicts. The code block in Hope this helps! |
It sure helps. Thank you! |
Should I remove the tests altogether then? |
Current coverage is 83.09% (diff: 100%)
|
Which tests?
|
The skipped tests. Which I removed in the PR. |
Following #599