Skip to content

Commit

Permalink
Make use of Sphinx inventories for cross references (#8682)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Feb 13, 2024
1 parent 832225b commit 14ce997
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 83 deletions.
141 changes: 68 additions & 73 deletions docs/api/standard_library_types.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/concepts/json_schema.md
Expand Up @@ -442,7 +442,7 @@ print(ModelB.model_json_schema())
"""
```

You can specify JSON schema modifications via the [`Field`][pydantic.fields.Field] constructor via `typing.Annotated` as well:
You can specify JSON schema modifications via the [`Field`][pydantic.fields.Field] constructor via [`typing.Annotated`][] as well:

```py output="json"
import json
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/strict_mode.md
Expand Up @@ -287,7 +287,7 @@ except ValidationError as exc:
[`pydantic.types.Strict`][pydantic.types.Strict]<br>

Pydantic also provides the [`Strict`](../api/types.md#pydantic.types.Strict) class, which is intended for use as
metadata with `typing.Annotated` class; this annotation indicates that the annotated field should be validated in
metadata with [`typing.Annotated`][] class; this annotation indicates that the annotated field should be validated in
strict mode:

```python
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/unions.md
Expand Up @@ -323,7 +323,7 @@ except ValidationError as e:
When `None` is returned, this `union_tag_not_found` error is raised.

!!! note
Using the [`typing.Annotated` fields syntax](../concepts/json_schema.md#typingannotated-fields) can be handy to regroup
Using the [[`typing.Annotated`][] fields syntax](../concepts/json_schema.md#typingannotated-fields) can be handy to regroup
the `Union` and `discriminator` information. See the next example for more details.

There are a few ways to set a discriminator for a field, all varying slightly in syntax.
Expand Down
2 changes: 1 addition & 1 deletion docs/errors/usage_errors.md
Expand Up @@ -424,7 +424,7 @@ except PydanticUserError as exc_info:

## `TypedDict` version {#typed-dict-version}

This error is raised when you use `typing.TypedDict`
This error is raised when you use [typing.TypedDict][]
instead of `typing_extensions.TypedDict` on Python < 3.12.

## Model parent field overridden {#model-field-overridden}
Expand Down
4 changes: 2 additions & 2 deletions docs/install.md
Expand Up @@ -7,8 +7,8 @@ pip install pydantic
Pydantic has a few dependencies:

* [`pydantic-core`](https://pypi.org/project/pydantic-core/): Core validation logic for _pydantic_ written in rust.
* [`typing-extensions`](https://pypi.org/project/typing-extensions/): Backport of the standard library `typing` module.
* [`annotated-types`](https://pypi.org/project/annotated-types/): Reusable constraint types to use with `typing.Annotated`.
* [`typing-extensions`](https://pypi.org/project/typing-extensions/): Backport of the standard library [typing][] module.
* [`annotated-types`](https://pypi.org/project/annotated-types/): Reusable constraint types to use with [`typing.Annotated`][].

If you've got Python 3.8+ and `pip` installed, you're good to go.

Expand Down
8 changes: 4 additions & 4 deletions docs/migration.md
Expand Up @@ -237,9 +237,9 @@ The following properties have been removed from or changed in `Field`:
- `unique_items`
- `allow_mutation` (use `frozen` instead)
- `regex` (use `pattern` instead)
- `final` (use the `typing.Final` type hint instead)
- `final` (use the [typing.Final][] type hint instead)

Field constraints are no longer automatically pushed down to the parameters of generics. For example, you can no longer validate every element of a list matches a regex by providing `my_list: list[str] = Field(pattern=".*")`. Instead, use `typing.Annotated` to provide an annotation on the `str` itself: `my_list: list[Annotated[str, Field(pattern=".*")]]`
Field constraints are no longer automatically pushed down to the parameters of generics. For example, you can no longer validate every element of a list matches a regex by providing `my_list: list[str] = Field(pattern=".*")`. Instead, use [`typing.Annotated`][] to provide an annotation on the `str` itself: `my_list: list[Annotated[str, Field(pattern=".*")]]`

* [TODO: Need to document any other backwards-incompatible changes to `pydantic.Field`]

Expand Down Expand Up @@ -698,7 +698,7 @@ We have completely overhauled the way custom types are defined in pydantic.
We have exposed hooks for generating both `pydantic-core` and JSON schemas, allowing you to get all the performance
benefits of Pydantic V2 even when using your own custom types.

We have also introduced ways to use `typing.Annotated` to add custom validation to your own types.
We have also introduced ways to use [`typing.Annotated`][] to add custom validation to your own types.

The main changes are:

Expand All @@ -707,7 +707,7 @@ The main changes are:
* `__modify_schema__` becomes `__get_pydantic_json_schema__`.
See [JSON Schema Customization](concepts/json_schema.md#schema-customization) for more information.

Additionally, you can use `typing.Annotated` to modify or provide the `__get_pydantic_core_schema__` and
Additionally, you can use [`typing.Annotated`][] to modify or provide the `__get_pydantic_core_schema__` and
`__get_pydantic_json_schema__` functions of a type by annotating it, rather than modifying the type itself.
This provides a powerful and flexible mechanism for integrating third-party types with Pydantic, and in some cases
may help you remove hacks from Pydantic V1 introduced to work around the limitations for custom types.
Expand Down
4 changes: 4 additions & 0 deletions mkdocs.yml
Expand Up @@ -172,8 +172,12 @@ plugins:
docstring_options:
ignore_init_summary: true
merge_init_into_class: true
show_signature_annotations: true
signature_crossrefs: true
extensions:
- docs/plugins/griffe_doclinks.py
import:
- https://docs.python.org/3/objects.inv
- mkdocs-simple-hooks:
hooks:
on_pre_build: 'docs.plugins.main:on_pre_build'
Expand Down

0 comments on commit 14ce997

Please sign in to comment.