Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Jan 26, 2024
1 parent 645f7f8 commit 867bbbb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/concepts/alias.md
Expand Up @@ -15,6 +15,9 @@ For examples of how to use `alias`, `validation_alias`, and `serialization_alias

## `AliasPath` and `AliasChoices`

??? api "API Documentation"
[`pydantic.config.with_config`][pydantic.config.with_config]<br>

??? api "API Documentation"

[`pydantic.aliases.AliasPath`][pydantic.aliases.AliasPath]<br>
Expand Down
10 changes: 10 additions & 0 deletions docs/concepts/config.md
Expand Up @@ -98,6 +98,16 @@ class User:

Alternatively, the [`with_config`][pydantic.config.with_config] decorator can be used to comply with type checkers.

```py
from typing_extensions import TypedDict

from pydantic import ConfigDict, with_config

@with_config(ConfigDict(str_to_lower=True))
class Model(TypedDict):
x: str
```

## Change behaviour globally

If you wish to change the behaviour of Pydantic globally, you can create your own custom `BaseModel`
Expand Down
4 changes: 3 additions & 1 deletion pydantic/config.py
Expand Up @@ -913,7 +913,9 @@ class Model(BaseModel):


def with_config(config: ConfigDict) -> Callable[[_TypeT], _TypeT]:
"""A convenience decorator to set a [Pydantic configuration](config.md) on a `TypedDict` or a `dataclass` from the standard library.
"""Usage docs: https://docs.pydantic.dev/2.6/concepts/config/#configuration-with-dataclass-from-the-standard-library-or-typeddict
A convenience decorator to set a [Pydantic configuration](config.md) on a `TypedDict` or a `dataclass` from the standard library.
Although the configuration can be set using the `__pydantic_config__` attribute, it does not play well with type checkers,
especially with `TypedDict`.
Expand Down

0 comments on commit 867bbbb

Please sign in to comment.