Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pydantic URLs #366

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

Sync and Async ODM (Object Document Mapper) for <a href="https://www.mongodb.com/"
target="_blank">MongoDB</a> based on standard Python type hints. Built on top of <a
href="https://pydantic-docs.helpmanual.io/" target="_blank">Pydantic</a> for model
href="https://docs.pydantic.dev/" target="_blank">Pydantic</a> for model
definition and validation.

Core features:
Expand Down
2 changes: 1 addition & 1 deletion docs/api_reference/bson.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This module provides helpers to build Pydantic Models containing BSON objects.

::: odmantic.bson.BSON_TYPES_ENCODERS

Encoders required to encode BSON fields (can be used in the Pydantic Model's `Config.json_encoders` parameter). See [pydantic: JSON Encoders](https://pydantic-docs.helpmanual.io/usage/exporting_models/#json_encoders){:target=blank_} for more details.
Encoders required to encode BSON fields (can be used in the Pydantic Model's `Config.json_encoders` parameter). See [pydantic: JSON Encoders](https://docs.pydantic.dev/latest/api/config/#pydantic.config.ConfigDict.json_encoders){:target=blank_} for more details.

## Custom BSON serializer annotation

Expand Down
10 changes: 5 additions & 5 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ To define choices, it's possible to use the standard `enum` classes:
{ "_id" : ObjectId("5f818f2dd5708527282c49b7"), "kind" : "small", "name" : "Spruce" }
```

If you try to use a value not present in the allowed choices, a [ValidationError](https://pydantic-docs.helpmanual.io/usage/models/#error-handling){:target=blank_} exception will be raised.
If you try to use a value not present in the allowed choices, a [ValidationError](https://docs.pydantic.dev/latest/usage/models/#error-handling){:target=blank_} exception will be raised.

!!! warning "Usage of `enum.auto`"
If you might add some values to an `Enum`, it's strongly recommended not to use the
Expand Down Expand Up @@ -159,7 +159,7 @@ Those types can be used directly as field types:
### Pydantic fields

Most of the types supported by pydantic are supported by ODMantic. See [pydantic:
Field Types](https://pydantic-docs.helpmanual.io/usage/types){:target=bank_} for more
Field Types](https://docs.pydantic.dev/latest/usage/types/types/){:target=bank_} for more
field types.

Unsupported fields:
Expand Down Expand Up @@ -208,7 +208,7 @@ descriptor using the `default` keyword argument.
Currently the default values are not validated yet during the model creation.

An inconsistent default value might raise a
[ValidationError](https://pydantic-docs.helpmanual.io/usage/models/#error-handling){:target=blank_}
[ValidationError](https://docs.pydantic.dev/latest/usage/models/#error-handling){:target=blank_}
while building an instance.

### Document structure
Expand Down Expand Up @@ -300,13 +300,13 @@ validation features provided by pydantic are available:
--8<-- "fields/validation_field_descriptor.py"
```

- Use strict types to prevent to coercion from compatible types ([pydantic: Strict Types](https://pydantic-docs.helpmanual.io/usage/types/#strict-types){:target=blank_})
- Use strict types to prevent to coercion from compatible types ([pydantic: Strict Types](https://docs.pydantic.dev/latest/usage/types/strict_types/){:target=blank_})
```python linenums="1"
--8<-- "fields/validation_strict_types.py"
```

- Define custom field validators ([pydantic:
Validators](https://pydantic-docs.helpmanual.io/usage/validators/){:target=blank_})
Validators](https://docs.pydantic.dev/latest/usage/validators/){:target=blank_})
```python linenums="1"
--8<-- "fields/custom_field_validators.py"
```
Expand Down
9 changes: 4 additions & 5 deletions docs/modeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ For example, defining a [text index](https://www.mongodb.com/docs/manual/core/in

Exactly as done with pydantic, it's possible to define custom model validators as
described in the [pydantic: Root
Validators](https://pydantic-docs.helpmanual.io/usage/validators/#root-validators){:target=blank_}
Validators](https://docs.pydantic.dev/latest/usage/validators/){:target=blank_}
documentation (this apply as well to Embedded Models).

In the following example, we will define a rectangle class and add two validators: The
Expand All @@ -141,7 +141,7 @@ ensure that the area of the rectangle is less or equal to 9.
### Advanced Configuration

The model configuration is done in the same way as with Pydantic models: using a
[ConfigDict](https://pydantic-docs.helpmanual.io/usage/model_config/){:target=blank_} `model_config` defined in the model body.
[ConfigDict](https://docs.pydantic.dev/latest/usage/model_config/){:target=blank_} `model_config` defined in the model body.

Here is an example of a model configuration:

Expand All @@ -159,7 +159,6 @@ class Event(Model):
}
```


#### Available options

`#!python collection: str`
Expand Down Expand Up @@ -187,7 +186,7 @@ class Event(Model):

`#!python schema_extra: dict` *(inherited from Pydantic)*
: A dict used to extend/update the generated JSON Schema, or a callable to
post-process it. See [Pydantic: Schema customization](https://pydantic-docs.helpmanual.io/usage/schema/#schema-customization){:target=_blank} for more details.
post-process it. See [Pydantic: Schema customization](https://docs.pydantic.dev/latest/usage/json_schema/#schema-customization){:target=_blank} for more details.

Default: `#!python {}`

Expand Down Expand Up @@ -222,7 +221,7 @@ class Event(Model):

For more details and examples about the options inherited from Pydantic, you can have a
look at [Pydantic: Model
Config](https://pydantic-docs.helpmanual.io/usage/model_config/){:target=blank_}
Config](https://docs.pydantic.dev/latest/usage/model_config/){:target=blank_}

!!! warning
Only the options described above are supported and other options from Pydantic can't
Expand Down
4 changes: 2 additions & 2 deletions docs/usage_fastapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ the error.
{"detail":[{"loc":["body","average_size"],"msg":"field required","type":"value_error.missing"}]}%
```
The validation error structure is the one that is defined by the [Pydantic:
ValidationError](https://pydantic-docs.helpmanual.io/usage/models/#error-handling){:target=blank_}
ValidationError](https://docs.pydantic.dev/latest/usage/models/#error-handling){:target=blank_}
exception.

Finally, specifying the `response_model` in the `app.put` decorator is not
Expand Down Expand Up @@ -712,7 +712,7 @@ We can then finish by saving and returning the updated tree.
: this field is **required** and an `int` value **must** be provided

(More details: [pydantic #1223](https://github.com/samuelcolvin/pydantic/issues/1223#issuecomment-594632324){:target=blank_},
[pydantic: Required fields](https://pydantic-docs.helpmanual.io/usage/models/#required-fields){:target=blank_})
[pydantic: Required fields](https://docs.pydantic.dev/latest/usage/models/#required-fields){:target=blank_})

By default [Model.model_update][odmantic.model._BaseODMModel.model_update], will not apply
values from unset (not explicitely populated) fields. Since we don't want to allow
Expand Down
Loading