Skip to content

Weird formatting of __new__ signature in error messages #5498

@GoldsteinE

Description

@GoldsteinE
from typing import Tuple, Dict, Any


class MyMeta(type):
    def __new__(cls, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> type:
        return type.__new__(name, bases, dict)

This MyMeta.__new__ has exactly same signature with type.__new__ in typeshed:
https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L88
But mypy thinks that it's incorrect and offers me to write two same cls args:

test.py:6: note: Possible overload variants:
test.py:6: note:     def __new__(cls, cls: Any, o: object) -> type
test.py:6: note:     def __new__(cls, cls: Any, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type

No mypy flags was used, mypy --version is 0.620

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions