Skip to content

@final(TypedDict).get() with unknown key returns object instead of None #12143

@Dreamsorcerer

Description

@Dreamsorcerer

See: #12143 (comment)


Original report:

With:

from typing import TypedDict, final

@final
class A(TypedDict):
    """Empty"""

a: A = {}
reveal_type(a.get("foo", None))

I expect to get None, but instead get object | Any.

Maybe the object should be replaced with None here? https://github.com/python/typeshed/blob/master/stdlib/typing.pyi#L717-L728
I'm not too sure how that works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions