Skip to content

Required[Type] does not trigger type checking for Type #533

@vhaldemar

Description

@vhaldemar

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Typeguard version

4.4.4

Python version

3.12

What happened?

Required/NotRequired types in TypedDict annotations are not allowing to make a recursive check for it's wrapped type.

How can we reproduce the bug?

In [123]: from typing import TypedDict, Required                                                      
                                                   
In [124]: import typeguard                  
                                                   
In [125]: class MyDict(TypedDict):
     ...:     foo: Required[int]                                                                      
     ...: 
                                                   
In [126]: typeguard.check_type({'foo': ''}, MyDict)
Out[126]: {'foo': ''}

In [127]: class MyDict(TypedDict):
     ...:     foo: int
     ...: 

In [128]: typeguard.check_type({'foo': ''}, MyDict)
---------------------------------------------------------------------------
TypeCheckError                            Traceback (most recent call last)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions