Repository: pydantic/pydantic

Issue:
arbitrary_types_allowed does not propagate to the model which is created for a NamedTuple
### 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

# Bug

When using a NamedTuple as a field in a pydantic model, it cannot have arbitrary types - even if `arbitrary_types_allowed` is `True` on the model. I found that when `create_model_from_namedtuple` is [called](https://github.com/samuelcolvin/pydantic/blob/master/pydantic/validators.py#L561), `config` is not passed (but for `TypedDict`, it _is_ [passed](https://github.com/samuelcolvin/pydantic/blob/master/pydantic/validators.py#L585)).

Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
             pydantic version: 1.9.1
            pydantic compiled: True
                 install path: /home/rory/lab/mres/task/co/.venv/lib/python3.9/site-packages/pydantic
               python version: 3.9.13 (main, May 27 2022, 11:07:19)  [GCC 12.1.0]
                     platform: Linux-5.18.7-arch1-1-x86_64-with-glibc2.35
     optional deps. installed: ['typing-extensions']
```

```py
from typing import NamedTuple
import pydantic

class Foo:
    pass

class Bar(NamedTuple):
    foo: Foo

class MyModel(pydantic.BaseModel):
    bar: Bar

    class Config:
        arbitrary_types_allowed = True
```
![image](https://user-images.githubusercontent.com/9436784/177740846-791a8db5-2c1f-459f-b97a-31951faaa7bf.png)



Discussion:

Resolving patch:
diff --git a/pydantic/validators.py b/pydantic/validators.py
--- a/pydantic/validators.py
+++ b/pydantic/validators.py
@@ -555,11 +555,14 @@ def pattern_validator(v: Any) -> Pattern[str]:
 NamedTupleT = TypeVar('NamedTupleT', bound=NamedTuple)
 
 
-def make_namedtuple_validator(namedtuple_cls: Type[NamedTupleT]) -> Callable[[Tuple[Any, ...]], NamedTupleT]:
+def make_namedtuple_validator(
+    namedtuple_cls: Type[NamedTupleT], config: Type['BaseConfig']
+) -> Callable[[Tuple[Any, ...]], NamedTupleT]:
     from .annotated_types import create_model_from_namedtuple
 
     NamedTupleModel = create_model_from_namedtuple(
         namedtuple_cls,
+        __config__=config,
         __module__=namedtuple_cls.__module__,
     )
     namedtuple_cls.__pydantic_model__ = NamedTupleModel  # type: ignore[attr-defined]
@@ -690,7 +693,7 @@ def find_validators(  # noqa: C901 (ignore complexity)
         return
     if is_namedtuple(type_):
         yield tuple_validator
-        yield make_namedtuple_validator(type_)
+        yield make_namedtuple_validator(type_, config)
         return
     if is_typeddict(type_):
         yield make_typeddict_validator(type_, config)


Test patch:
diff --git a/tests/test_annotated_types.py b/tests/test_annotated_types.py
--- a/tests/test_annotated_types.py
+++ b/tests/test_annotated_types.py
@@ -146,6 +146,29 @@ class Model(BaseModel):
         Model.parse_obj({'t': [-1]})
 
 
+def test_namedtuple_arbitrary_type():
+    class CustomClass:
+        pass
+
+    class Tup(NamedTuple):
+        c: CustomClass
+
+    class Model(BaseModel):
+        x: Tup
+
+        class Config:
+            arbitrary_types_allowed = True
+
+    data = {'x': Tup(c=CustomClass())}
+    model = Model.parse_obj(data)
+    assert isinstance(model.x.c, CustomClass)
+
+    with pytest.raises(RuntimeError):
+
+        class ModelNoArbitraryTypes(BaseModel):
+            x: Tup
+
+
 def test_typeddict():
     class TD(TypedDict):
         a: int