Skip to content

"extra" config not respected for TypedDicts in functions #3161

@mayanksharma3

Description

@mayanksharma3

Checks

  • I added a descriptive title to this issue
  • I have searched (google, github) for similar issues and couldn't find anything
  • I have read and followed the docs and still think this is a bug

Bug

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.8.2
            pydantic compiled: False
                 install path: /home/msharma216/.local/lib/python3.8/site-packages/pydantic
               python version: 3.8.0 (default, Feb 25 2021, 22:10:10)  [GCC 8.4.0]
                     platform: Linux-4.4.0-19041-Microsoft-x86_64-with-glibc2.27
     optional deps. installed: ['typing-extensions']

When trying to use the validate_arguments decorator, I face the issue of getting validation errors for an extra attribute for a TypedDict as below:

from typing_extensions import TypedDict

from pydantic import validate_arguments, Extra


class TypedTest(TypedDict):
    y: str


@validate_arguments(config={'extra': Extra.allow})
def test(other: TypedTest):
    pass


test(other={'y': 'b', 'z': 'a'})

Output:

pydantic.error_wrappers.ValidationError: 1 validation error for Test
other -> z
  extra fields not permitted (type=value_error.extra)

Expected: No errors

Anything I have missed that would let this validation pass for extra attributes in the TypedDict?

Thanks very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions