Is your feature request related to a problem? Please describe.
from __future__ import annotations
from typing import Mapping, TypedDict, final
FileTypes = bytes
# this has to be key agnostic
RequestFiles = Mapping[str, FileTypes]
def post(files: RequestFiles | None = None):
...
@final
class FileParams(TypedDict):
file: FileTypes
def foo(files: FileParams):
# error: Argument of type "FileParams" cannot be assigned to parameter "files" of type "RequestFiles | None" in function "post"
post(files)
Describe the solution you'd like
Ideally pyright could infer that the FileParams TypedDict could be safely passed to the post function as it is known to only contain keys with the type FileTypes and cannot be subclassed to add more keys because it is decorated with @final.
Additional context
I apologise if there's prior discussion surrounding this, I couldn't find any.
original issue: https://github.com/microsoft/pyright/issues/3526