-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
enhancement requestNew feature or requestNew feature or request
Description
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.
rattrayalex and ringohoffman
Metadata
Metadata
Assignees
Labels
enhancement requestNew feature or requestNew feature or request