Skip to content

TypedDict.values() always returns object. #10759

@Dreamsorcerer

Description

@Dreamsorcerer
from typing import TypedDict

class A(TypedDict):
    a: str

def foo(a: A):
    for v in reveal_type(a.values()):
        v.lower()

This produces:

test.py:7: note: Revealed type is 'typing.ValuesView[builtins.object]'
test.py:8: error: "object" has no attribute "lower"
Found 1 error in 1 file (checked 1 source file)

Expected Behavior

TypedDict.values() to return a different type if all values of a TypedDict are of the same type.

Your Environment

  • Mypy version used: 0.910

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions