Skip to content

subclass of dict won't specialize from constructor call #588

@carljm

Description

@carljm
from typing import TypeVar
from typing_extensions import reveal_type

_K = TypeVar("_K")
_V = TypeVar("_V")

class MyDict(dict[_K, _V]):
    pass

a = MyDict(foo=1)
reveal_type(a)

which gives

error[no-matching-overload] mwe.py:13:5: No overload of bound method `__init__` matches arguments
info[revealed-type] mwe.py:14:13: Revealed type: `MyDict[Unknown, Unknown]`

and works with mypy.

Originally posted by @MarcinKonowalczyk in #587

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggenericsBugs or features relating to ty's generics implementation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions