Repository: samuelcolvin/pydantic (python)

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!

Pull request:
feat: support custom `extra` in `validate_arguments`
<!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
<!-- See https://pydantic-docs.helpmanual.io/contributing/ for help on Contributing -->

## Change Summary

<!-- Please give a short summary of the changes. -->

## Related issue number
fix #3161
<!-- Are there any issues opened that will be resolved by merging this change? -->

## Checklist

* [x] Unit tests for the changes exist
* [ ] Tests pass on CI and coverage remains at 100%
* [x] Documentation reflects the changes where applicable
* [x] `changes/<pull request or issue id>-<github username>.md` file added describing change
  (see [changes/README.md](https://github.com/samuelcolvin/pydantic/blob/master/changes/README.md) for details)
* [ ] My PR is ready to review, **please add a comment including the phrase "please review" to assign reviewers**


Patch:
diff --git a/changes/3161-PrettyWood.md b/changes/3161-PrettyWood.md
new file mode 100644
index 000000000..3e037e594
--- /dev/null
+++ b/changes/3161-PrettyWood.md
@@ -0,0 +1,1 @@
+`validate_arguments` now supports `extra` customization (used to always be `Extra.forbid`)
\ No newline at end of file
diff --git a/pydantic/decorator.py b/pydantic/decorator.py
index ca709b405..ced49532a 100644
--- a/pydantic/decorator.py
+++ b/pydantic/decorator.py
@@ -254,6 +254,6 @@ class ValidatedFunction:
                 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
index ea06368b3..97b78f88e 100644
--- a/tests/test_decorator.py
+++ b/tests/test_decorator.py
@@ -6,9 +6,9 @@ from pathlib import Path
 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'}