Skip to content
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

Now __new__ in a metaclass must return a subtype of type #11420

Merged
merged 1 commit into from
Nov 1, 2021
Merged

Now __new__ in a metaclass must return a subtype of type #11420

merged 1 commit into from
Nov 1, 2021

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Oct 31, 2021

Closes #11398

Now cases like

from typing import Type

class MyMetaClass(type):
    def __new__(cls, name, bases, attrs) -> Type['MyClass']:
        pass

class MyClass(metaclass=MyMetaClass):
    pass

Will pass.

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.

Nice! Thanks for the PR.

@JukkaL JukkaL merged commit bddc8bf into python:master Nov 1, 2021
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
…thon#11398 (python#11420)

Closes python#11398

Now cases like 

```python
from typing import Type

class MyMetaClass(type):
    def __new__(cls, name, bases, attrs) -> Type['MyClass']:
        pass

class MyClass(metaclass=MyMetaClass):
    pass
```

will pass.
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.

enhance the comprehension of the __new__ method of a metaclass
2 participants