Skip to content

Do not support metaclasses not inheriting from type #2820

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

Merged
merged 3 commits into from
Feb 7, 2017

Conversation

elazarg
Copy link
Contributor

@elazarg elazarg commented Feb 7, 2017

Fix #2818.

ABCMeta requires special treatment.

Related: #2475

@elazarg elazarg changed the title Do not support classes not inheriting from type Do not support metaclasses not inheriting from type Feb 7, 2017
@elazarg
Copy link
Contributor Author

elazarg commented Feb 7, 2017

@ilevkivskyi


reveal_type(A.x) # E: Revealed type is 'builtins.int'
A.x # E: "A" has no attribute "x"
Copy link
Member

@ilevkivskyi ilevkivskyi Feb 7, 2017

Choose a reason for hiding this comment

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

I would add a test that checks that "indirect" inheritance works, like:

class M1(type):
    x = 0
class M2(M1): pass
class C(metaclass=M2):
    pass
reveal_type(C.x) # E: Revealed type is 'builtins.int'

Otherwise LGTM.

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 7, 2017

Looks good -- but there's now a merge conflict.

@elazarg
Copy link
Contributor Author

elazarg commented Feb 7, 2017

Fixed.

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 7, 2017

Thanks!

@JukkaL JukkaL merged commit 452a64f into python:master Feb 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants