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

Skip to content

Several plugin hooks don't work on unions #6117

@ilevkivskyi

Description

@ilevkivskyi

Some plugin hooks (in particular for TypedDicts) are not called if the underlying "base" type is a union. For example:

from typing import Union
from mypy_extensions import TypedDict

class TDA(TypedDict):
    a: int

class TDB(TypedDict):
    a: int

td: Union[TDA, TDB]

reveal_type(td['a'])  # Revealed type is 'builtins.object*'
reveal_type(td.pop('a'))  # Revealed type is 'builtins.object'
                          # Argument 1 to "pop" of "TypedDict" has incompatible type "str"; expected "NoReturn"

This affects both "builtin" plugins and user defined plugins.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions