Repository: pydantic/pydantic

Issue:
"extra" config not respected for TypedDicts in functions
### Checks

* [x] I added a descriptive title to this issue
* [x] I have searched (google, github) for similar issues and couldn't find anything
* [x] I have read and followed [the docs](https://pydantic-docs.helpmanual.io/) and still think this is a bug

<!-- Sorry to sound so draconian, but every second saved replying to issues is time spend improving pydantic :-) -->

# 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']

```
<!-- or if you're using pydantic prior to v1.3, manually include: OS, python version and pydantic version -->

<!-- Please read the [docs](https://pydantic-docs.helpmanual.io/) and search through issues to
confirm your bug hasn't already been reported. -->

<!-- Where possible please include a self-contained code snippet describing your bug: -->

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:

```py
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!


Comments:

Patch:
diff --git a/pydantic/decorator.py b/pydantic/decorator.py
--- a/pydantic/decorator.py
+++ b/pydantic/decorator.py
@@ -254,6 +254,6 @@ def check_duplicate_kwargs(cls, v: Optional[List[str]]) -> None:
                 raise TypeError(f'multiple values for argument{plural}: {keys}')
 
             class Config(CustomConfig):
-                extra = Extra.forbid
+                extra = getattr(CustomConfig, 'extra', Extra.forbid)
 
         self.model = create_model(to_camel(self.raw_function.__name__), __base__=DecoratorBaseModel, **fields)


Test patch:
diff --git a/tests/test_decorator.py b/tests/test_decorator.py
--- a/tests/test_decorator.py
+++ b/tests/test_decorator.py
@@ -6,9 +6,9 @@
 from typing import List
 
 import pytest
-from typing_extensions import Annotated
+from typing_extensions import Annotated, TypedDict
 
-from pydantic import BaseModel, Field, ValidationError, validate_arguments
+from pydantic import BaseModel, Extra, Field, ValidationError, validate_arguments
 from pydantic.decorator import ValidatedFunction
 from pydantic.errors import ConfigError
 
@@ -427,3 +427,20 @@ def foo(dt: datetime = Field(default_factory=lambda: 946684800), /):
     )
     assert module.foo() == datetime(2000, 1, 1, tzinfo=timezone.utc)
     assert module.foo(0) == datetime(1970, 1, 1, tzinfo=timezone.utc)
+
+
+def test_validate_extra():
+    class TypedTest(TypedDict):
+        y: str
+
+    @validate_arguments(config={'extra': Extra.allow})
+    def test(other: TypedTest):
+        return other
+
+    assert test(other={'y': 'b', 'z': 'a'}) == {'y': 'b', 'z': 'a'}
+
+    @validate_arguments(config={'extra': Extra.ignore})
+    def test(other: TypedTest):
+        return other
+
+    assert test(other={'y': 'b', 'z': 'a'}) == {'y': 'b'}