Repository: pydantic/pydantic

Issue:
`create_model` docstring incorrect for custom-specified `Field`s
### 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

Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
$ python -c "import pydantic.utils; print(pydantic.utils.version_info())"
             pydantic version: 1.9.0
            pydantic compiled: True
                 install path: <...>/lib/python3.8/site-packages/pydantic
               python version: 3.8.12 (default, Feb 16 2022, 11:03:41)  [Clang 13.0.0 (clang-1300.0.27.3)]
                     platform: macOS-12.1-x86_64-i386-64bit
     optional deps. installed: ['typing-extensions']
```

The docstring for `create_model` has the following to say about the field definitions:

```
    :param field_definitions: fields of the model (or extra fields if a base is supplied)
        in the format `<name>=(<type>, <default default>)` or `<name>=<default value>, e.g.
        `foobar=(str, ...)` or `foobar=123`, or, for complex use-cases, in the format
        `<name>=<FieldInfo>`, e.g. `foo=Field(default_factory=datetime.utcnow, alias='bar')`
```

which suggests to use `foo=Field(default_factory=...)`, but that throws an error since the `foo` field doesn't have a type:

```py
from datetime import datetime
from pydantic import Field, create_model


Config = create_model("Config", foo=Field(default_factory=datetime.utcnow))
print(Config())

```

produces

```
pydantic.errors.ConfigError: you need to set the type of field 'foo' when using `default_factory`
```

Instead, Pydantic expects the form `<name>=(<type>, <FieldInfo>)`:

```py
from datetime import datetime
from pydantic import Field, create_model


Config = create_model("Config", foo=(datetime, Field(default_factory=datetime.utcnow)))
print(Config())
```

correctly produces the expected output:

```
foo=datetime.datetime(2022, 5, 2, 22, 47, 20, 771589)
```

`create_model` docstring incorrect for custom-specified `Field`s
### 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

Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
$ python -c "import pydantic.utils; print(pydantic.utils.version_info())"
             pydantic version: 1.9.0
            pydantic compiled: True
                 install path: <...>/lib/python3.8/site-packages/pydantic
               python version: 3.8.12 (default, Feb 16 2022, 11:03:41)  [Clang 13.0.0 (clang-1300.0.27.3)]
                     platform: macOS-12.1-x86_64-i386-64bit
     optional deps. installed: ['typing-extensions']
```

The docstring for `create_model` has the following to say about the field definitions:

```
    :param field_definitions: fields of the model (or extra fields if a base is supplied)
        in the format `<name>=(<type>, <default default>)` or `<name>=<default value>, e.g.
        `foobar=(str, ...)` or `foobar=123`, or, for complex use-cases, in the format
        `<name>=<FieldInfo>`, e.g. `foo=Field(default_factory=datetime.utcnow, alias='bar')`
```

which suggests to use `foo=Field(default_factory=...)`, but that throws an error since the `foo` field doesn't have a type:

```py
from datetime import datetime
from pydantic import Field, create_model


Config = create_model("Config", foo=Field(default_factory=datetime.utcnow))
print(Config())

```

produces

```
pydantic.errors.ConfigError: you need to set the type of field 'foo' when using `default_factory`
```

Instead, Pydantic expects the form `<name>=(<type>, <FieldInfo>)`:

```py
from datetime import datetime
from pydantic import Field, create_model


Config = create_model("Config", foo=(datetime, Field(default_factory=datetime.utcnow)))
print(Config())
```

correctly produces the expected output:

```
foo=datetime.datetime(2022, 5, 2, 22, 47, 20, 771589)
```



Discussion:
Thanks for pointing this out, PR welcome to correct the docstring.
This also seems to affect the docstring example 

> ... for complex use-cases, in the format `<name>=<FieldInfo>`.

For example:

```python terminal
>>> from pydantic import create_model
>>> from pydantic import BaseModel
>>> class MyModel(BaseModel):
...     attrib: str
... 
>>> create_model("Test", attrib=MyModel.__fields__["attrib"].field_info)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pydantic/main.py", line 972, in pydantic.main.create_model
  File "pydantic/main.py", line 228, in pydantic.main.ModelMetaclass.__new__
  File "pydantic/fields.py", line 488, in pydantic.fields.ModelField.infer
  File "pydantic/fields.py", line 419, in pydantic.fields.ModelField.__init__
  File "pydantic/fields.py", line 539, in pydantic.fields.ModelField.prepare
  File "pydantic/fields.py", line 801, in pydantic.fields.ModelField.populate_validators
  File "pydantic/validators.py", line 723, in find_validators
RuntimeError: no validator found for <class 'pydantic.fields.UndefinedType'>, see `arbitrary_types_allowed` in Config
>>> create_model("Test", attrib=(str, MyModel.__fields__["attrib"].field_info))
<class 'pydantic.main.Test'>
```
Thanks for pointing this out, PR welcome to correct the docstring.
This also seems to affect the docstring example 

> ... for complex use-cases, in the format `<name>=<FieldInfo>`.

For example:

```python terminal
>>> from pydantic import create_model
>>> from pydantic import BaseModel
>>> class MyModel(BaseModel):
...     attrib: str
... 
>>> create_model("Test", attrib=MyModel.__fields__["attrib"].field_info)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pydantic/main.py", line 972, in pydantic.main.create_model
  File "pydantic/main.py", line 228, in pydantic.main.ModelMetaclass.__new__
  File "pydantic/fields.py", line 488, in pydantic.fields.ModelField.infer
  File "pydantic/fields.py", line 419, in pydantic.fields.ModelField.__init__
  File "pydantic/fields.py", line 539, in pydantic.fields.ModelField.prepare
  File "pydantic/fields.py", line 801, in pydantic.fields.ModelField.populate_validators
  File "pydantic/validators.py", line 723, in find_validators
RuntimeError: no validator found for <class 'pydantic.fields.UndefinedType'>, see `arbitrary_types_allowed` in Config
>>> create_model("Test", attrib=(str, MyModel.__fields__["attrib"].field_info))
<class 'pydantic.main.Test'>
```

Resolving patch:
diff --git a/pydantic/main.py b/pydantic/main.py
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -943,7 +943,9 @@ def create_model(
     :param field_definitions: fields of the model (or extra fields if a base is supplied)
         in the format `<name>=(<type>, <default default>)` or `<name>=<default value>, e.g.
         `foobar=(str, ...)` or `foobar=123`, or, for complex use-cases, in the format
-        `<name>=<FieldInfo>`, e.g. `foo=Field(default_factory=datetime.utcnow, alias='bar')`
+        `<name>=<Field>` or `<name>=(<type>, <FieldInfo>)`, e.g.
+        `foo=Field(datetime, default_factory=datetime.utcnow, alias='bar')` or
+        `foo=(str, FieldInfo(title='Foo'))`
     """
 
     if __base__ is not None:


Test patch: