Skip to content

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

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions