Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
JukkaL merged 1 commit into
python:masterfrom
sobolevn:issue-11398
Nov 1, 2021
Merged

Now __new__ in a metaclass must return a subtype of type#11420
JukkaL merged 1 commit into
python:masterfrom
sobolevn:issue-11398

Conversation

@sobolevn

@sobolevn sobolevn commented Oct 31, 2021

Copy link
Copy Markdown
Member

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.

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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