Skip to content

check_type does not check required fields when mixing required and non-required fields in TypedDict #101

@ksaaskil

Description

@ksaaskil

Hi, thanks for the awesome library! A recent fix for an issue (#94) added support for totality in TypedDict, thanks for that! I'm trying to mix required and non-required fields in TypedDict as instructed in mypy documentation:

class MovieBase(TypedDict):
    name: str
    year: int

class Movie(MovieBase, total=False):
    based_on: str

This definition should make name and year required fields in Movie.

However, check_type does not seem to complain if those are missing:

from typeguard import check_type

movie = Movie()   # Missing `name` and `year` , type-checker complains
check_type("movie", movie, Movie)  # Does not raise error but it should?

Any idea what might be wrong here? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions