Commit Graph

460 Commits

Author SHA1 Message Date
David Brochart a7e896c5a3 Update Jupyter's use of pydantic (#4082)
* Update Jupyter's use of pydantic

* Fix markdown link
2022-05-16 11:26:31 +01:00
Blake Naccarato f419710381 Fix typo # pylance: ignore > # pyright: ignore (#4072)
In #3972, `# pyright: ignore` was added in multiple places in the docs, and `# pylance: ignore` only once. I believe it's a typo, as AFAIK such a typing ignore comment flag doesn't exist.
2022-05-13 19:10:55 +01:00
dependabot[bot] 268588b08d build(deps): bump mkdocs-material from 8.2.8 to 8.2.14 (#4063)
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.2.8 to 8.2.14.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/8.2.8...8.2.14)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-13 16:29:06 +01:00
Samuel Colvin 74403c2f15 test pyright with pydantic (#3972)
* test pyright with pydantic

* rename file to avoid pytest running it

* try another name 😴

* add docs about BaseSettings and Field

* add change
2022-05-11 19:00:37 +01:00
dependabot[bot] a1b7aa2a63 build(deps): bump hypothesis from 6.41.0 to 6.46.3 (#4059)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.41.0 to 6.46.3.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.41.0...hypothesis-python-6.46.3)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-11 18:56:10 +01:00
dependabot[bot] 3726059610 build(deps): bump mkdocs-material from 8.2.8 to 8.2.12 (#4038)
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.2.8 to 8.2.12.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/8.2.8...8.2.12)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-11 18:00:13 +01:00
Samuel Colvin 8997cc5961 Remove benchmarks completely (#3973)
* removing benchmarks completely

* [no ci] add change
2022-04-04 13:29:17 +01:00
Gary Donovan 7f90b2f342 Remove incorrect comment about lazy evaluation of setting sources (#3806)
* Remove incorrect comment about lazy evaluation of setting sources

It looks like the current implementation always evaluates every source (https://github.com/samuelcolvin/pydantic/blob/9d631a3429a66f30742c1a52c94ac18ec6ba848d/pydantic/env_settings.py#L73) before coalescing them into a single dictionary to pass to `BaseModel`. So the comment about lazy evaluation is incorrect and should be removed.

* Add changelog
2022-04-02 15:25:43 +01:00
Natan Yellin 55b34ef946 Add Robusta.dev to list of Pydantic users (#3715)
* add robusta.dev to pydantic users

* update robusta.dev description and fix typo
2022-04-02 14:42:51 +01:00
Tom Milligan 02eb182db0 fix: clarify that discriminated unions do not support singletons (#3639) 2022-04-02 14:06:11 +01:00
dependabot[bot] 19064138e4 build(deps): bump hypothesis from 6.31.6 to 6.41.0 (#3964)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.31.6 to 6.41.0.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.31.6...hypothesis-python-6.41.0)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-02 08:56:39 +01:00
dependabot[bot] bf5fdfc618 build(deps): bump black from 21.12b0 to 22.3.0 (#3950)
* build(deps): bump black from 21.12b0 to 22.3.0

Bumps [black](https://github.com/psf/black) from 21.12b0 to 22.3.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/commits/22.3.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* apply new black styles, fix docs

* try upgrading pip before fastapi tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-04-02 08:35:55 +01:00
Guilhem C 90628e1c2b docs: fix typo in settings management page (#3781) 2022-04-01 19:47:05 +01:00
dependabot[bot] 1fb438bc0b build(deps): bump mkdocs-material from 8.1.3 to 8.2.3 (#3865)
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.1.3 to 8.2.3.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/8.1.3...8.2.3)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-01 22:34:35 +00:00
Samuel Colvin 6f46a5a146 drop python3.6 support (#3605)
* drop python3.6 support

* revert small change

* fix 3.7 failures

* more cases and cleanup

* add change description
2022-01-02 13:53:45 +00:00
Samuel Colvin 6f26a1ce18 Support mypy 0.910 to 0.930 including CI tests (#3594)
* cleanup bumping mypy to 0.930, #3573

* add tests for old mypy

* tweak test-old-mypy job

* alter mypy plugin to work with older versions

* mypy.py compatibility with multiple versions

* fix mypy tests to allow for varied output

* toml parsing, fix #3579

* formatting :-(

* ignore missing types for toml package

* remove unused ignore_missing_imports

* undo removal of ignore_missing_imports for dotenv

* tweak coverage ignore

* fully uninstall mypy and toml/tomli
2021-12-30 13:49:43 +00:00
Eric Jolibois edad0dbc46 fix: keep old behaviour of json() by default (#3542)
* fix: handle basemodel fallback for custom encoders

* put back old behaviour and add to_dict

* typo

Co-authored-by: Christian Bundy <christianbundy@fraction.io>

Co-authored-by: Christian Bundy <christianbundy@fraction.io>
2021-12-24 13:14:13 +00:00
dependabot[bot] 30015aca95 build(deps): bump hypothesis from 6.31.4 to 6.31.6 (#3554)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.31.4 to 6.31.6.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.31.4...hypothesis-python-6.31.6)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-24 13:10:50 +00:00
dependabot[bot] 06bfbc8ec3 build(deps): bump mkdocs-material from 8.1.1 to 8.1.3 (#3555)
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.1.1 to 8.1.3.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/8.1.1...8.1.3)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-24 13:10:43 +00:00
Eric Jolibois 81b13ff3b4 fix: rename schema util into schema_of (#3547) 2021-12-22 19:42:56 +00:00
Mark Trifonov be246701c5 Nested env (#3159)
* Environment names for complex types #2304

* nested env disabled by default

* cleanup

* nested env settings: simplified and mypy fixes

* nested env settings: config, test, doc

* nested env settings: changes file

* nested env settings: cleanup

* Apply suggestions from code review

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>

* Apply suggested changes from code review

* lint fix

* changes from code review

* simplify explosing env vars

* linting

Co-authored-by: Mark Trifonov <>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2021-12-18 20:56:14 +00:00
Jaakko Moisio 63337fbadc Add optional field argument to __modify_schema__() (#3434)
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2021-12-18 20:55:22 +00:00
dependabot[bot] b03d3ed2ca build(deps): bump hypothesis from 6.30.1 to 6.31.4 (#3520)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.30.1 to 6.31.4.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.30.1...hypothesis-python-6.31.4)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-18 20:54:58 +00:00
dependabot[bot] cd688f40a2 build(deps): bump mkdocs-material from 8.0.5 to 8.1.1 (#3518)
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.0.5 to 8.1.1.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/8.0.5...8.1.1)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-18 20:54:49 +00:00
Marcelo Trylesinski 7eaa582980 Add AmqpDsn class (#3254)
* Add RabbitmqDsn

Will update once finished - haven't looked at the CONTRIB yet. Want to test locally to see if it works.

* added tests; added to docs

* added changes

* fixed import in networks.py

* fixed linting issues; fixed __init__.py import issue

* sorted imports

* added trailing comma on imports

* Merge master

* Change class name from RabbitmqDsn to RabbitMqDsn

* Format code

* Rename change file and prettify content

* Fix RabbitMQ name on documentation

* Add a trivial test

* Address Samuel and Nuno's comments

* Refactor AMQP tests according to Redis tests style

* Update docs/examples/settings_main.py

* cleanup

Co-authored-by: Thomas <thomas@9bitbyte.com>
Co-authored-by: Thomas Crha <tom.crha@dragonflytechnologies.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2021-12-18 20:40:16 +00:00
Eric Jolibois c834f3419d Support discriminated union (#2336)
* feat: add discriminated union

* feat: add OpenAPI spec schema

* test: add basic example for generated schema

* test: add validation tests

* docs: add basic documentation

* fix: support ForwardRef

* test: add ForwardRef case

* fix: false positive lint error

https://github.com/PyCQA/pyflakes/pull/600

* improve error

* add schema/schema_json utils

* fix tests after merge

* refactor: add `discriminator` attribute to `FieldInfo`

* refactor: @cybojenix remarks

* fix schema with forward ref

* start nested

* feat: add allowed values in error message

* fix wrong check

Same example with

```
class FooDomainA(BaseModel):
    __root__: Union[FooDomainAA, FooDomainAB]
```

(without a discriminator)
should obviously be valid

* test: add nested examples

* remove uncovered code as we don't need it

* docs: add nested example

* fix: support properly Annotated Field syntax

* support naked annotated

* fix: handle TypeError

* make error loc more explicit

* fix behaviour with basemodel instance as value

* support schema for dataclasses

* tweak examples

* refactor: context manager just around code that fails

* refactor: add docstring + tweak on `get_sub_types`

* refactor: move `get_discriminator_values` in `utils.py`

* refactor: create `MissingDiscriminator` and `InvalidDiscriminator`

* refactor: move logic in `_validate_discriminated_union`

* refactor: remove `DiscriminatedUnionConfig`

* docs: schema/schema_json

* tests: add tests with other `Literal` types

* update 3.10

* add schema docstring

* weird bug on 3.8 with `Literal[None]`

* bump to view docs & coverage

* bump to prompt tests

* move tests in dedicated file

* chore: rewording

* refactor: replace property by direct slot

* refactor: faster check

* refactor: missing discriminator

* refactor: change error to ConfigError

* refactor: use display_as_type

* fix: mypy

* fix: duplicate

* feat: handle alias

* feat: handle nested unions

* tweak first example

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2021-12-18 16:31:35 +00:00
Sebastián Ramírez 61d30aed7a Add support for decimal-specific configs in Field() (#3507)
*  Add support for Decimal-specific configs in Field()

*  Add/update tests for condecimal and variant with Field()

* 📝 Update schema - Field() docs including Decimal-specific configs

* 📝 Add PR changes file
2021-12-11 11:21:06 +00:00
Nuno André 91ecfd651e feat: Add unique items validation to constrained lists (#2618)
* Add unique items validation to constrained list

* add unique_items to field and schema
add failover for unhashable types
check keyword value to call the validator
add some tests

* update unique_items validation

Co-authored-by: Nuno André Novo <nuno.novo@forensic-security.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2021-12-10 10:04:06 +00:00
Michael Rios 043d16bcf8 Update validator function name in examples to show that value must b… (#3327)
* Update validator function name in  examples to show that value must be bar vs must contain a space

* Add md file in
2021-12-08 23:17:08 +00:00
Eric Jolibois 8c2c602c1b feat: add confrozenset() (#2672)
* feat: add `confrozenset()`

* fix: add tests for allowed_schemas
2021-12-07 22:11:42 +00:00
Eric Jolibois 458f257dcb feat: make JSON serialization of referenced pydantic models possible (#2650)
* feat: make JSON serialization of referenced pydantic models possible

* add docs

* chore: @samuelcolvin remarks
2021-12-07 22:01:11 +00:00
Eric Jolibois c38c463137 feat: add Config.smart_union option (#2092)
* feat: add `Config.smart_union` to prevent coercion in `Union` if possible

* docs: write some documentation

* Update docs/usage/model_config.md

Thanks @djpugh

Co-authored-by: David J Pugh <6003255+djpugh@users.noreply.github.com>

* improve doc

* support 3.10

* improve smart_union

* Update docs/usage/types.md

Co-authored-by: David J Pugh <6003255+djpugh@users.noreply.github.com>

* put new sentence inside warning block

* docs: reorder

* rename is_union_origin into is_union

* inverse and condition for perf

* fix doc

Co-authored-by: David J Pugh <6003255+djpugh@users.noreply.github.com>
2021-12-07 21:58:52 +00:00
q0w 4af50043f1 docs: Print name classes for __concrete_name__ example (#3470)
* Print name classes

* use `repr` to display class name

Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
2021-12-07 10:45:39 +01:00
Eric Jolibois 0ebea889f6 build(deps): bump requirements (#3495)
* chore(deps): bump requirements

* style: format after black bump
2021-12-07 10:36:41 +01:00
Yurii Karabas 415eb54f96 Try to evaluate forward refs after model created (#2588)
* Try to evaluate forward refs after model created

* Upadate docs and remove code duplication

* Update changes/2588-uriyyo.md

Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>

* Update docs/usage/postponed_annotations.md

Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>

* Remove unused import

Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
2021-12-05 14:20:48 +00:00
Eric Jolibois a35cde90af feat(schema): set minItems and maxItems in JSON schema for tuples (#2497)
* feat(schema): enforce length in generated JSON schema for tuple type

* docs: add change file

* docs: update documentation

* simplify a bit

* always set array
2021-12-05 13:20:07 +00:00
Colin Watson cc1cb4826c Fix "dataclasess" typos (#3411) 2021-11-18 23:41:56 +01:00
Tom Hacohen 8afdaab4ac Schema.md: use consistent (American) spelling (#3207)
Customisation is the British spelling. Below (and elsewhere) the American
spelling (customization) is used.
2021-10-27 01:28:27 +02:00
Josh Smith 7acac76f3c fix minor typo (#3240) 2021-10-27 01:26:52 +02:00
Dylan Leroux 36140bb177 typo (#3242) 2021-10-27 01:26:04 +02:00
Eric Jolibois 28f7b1ba58 build(deps): bump requirements (#3363) 2021-10-27 01:12:20 +02:00
Greg Wilson d2625d6052 docs: small change to wording in note (#3347) 2021-10-27 00:55:04 +02:00
dependabot[bot] eac8a457d1 build(deps): bump hypothesis from 6.18.0 to 6.24.0 (#3353)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.18.0 to 6.24.0.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.18.0...hypothesis-python-6.24.0)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-27 00:41:04 +02:00
Eric Jolibois 4be3f45e20 chore(deps): bump mkdocs (#3168)
* chore(deps-dev): bump mkdocs requirements

* fix: google analytics

`google_analytics` is deprecated and mkdocs raises an error in strict mode
Switched to new syntax
https://github.com/squidfunk/mkdocs-material/issues/2055
https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics
2021-10-12 22:46:47 +01:00
dependabot[bot] c256dccbb3 build(deps): bump hypothesis from 6.17.4 to 6.18.0 (#3183)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.17.4 to 6.18.0.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.17.4...hypothesis-python-6.18.0)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-11 10:49:52 +02:00
Sebastián Ramírez 45db4ad3aa Add autocomplete support for VS Code, via dataclass_transform (#2721)
*  Add autocomplete support for VS Code, via dataclass_transform

* 📝 Update changes

* 📝 Add docs for VS Code

* 📝 Clarify strict type error checks alternatives, include example with cast()

* ♻️ Update BaseSettings annotation to improve editor support

keeping editor support for BaseSetting's custom Config, but preventing __config__ from showing in constructor on editors supporting dataclass_transform

* 🎨 Remove unused type: ignore comment

* 🎨 Update type annotations for BaseSettings and BaseModel to use ClassVar where suitable

to improve editor support with type annotations and dataclass_transform

* 🎨 Apply ClassVars again

* 📝 Simplify VS Code docs terms

refer mainly to Pylance and clarify the relationship with Pyright

* 📝 Add link to Pylance FAQ

Co-authored-by: PrettyWood <em.jolibois@gmail.com>
2021-09-06 12:13:02 +02:00
John Walk 0c2f69c500 Toml support for pydantic-mypy plugin config (#2908)
* add toml reader

* fix path

* skip configparser step

* fix quotes

* full pyproject.toml check

* add doc note

* cleaner formatting, raise ValueError for non-bool

* fix tests

* add bad config test case

* add changelog file.

* bump mypy to 0.902

* tweak change MD, fix formatting in requirements

* import check around toml

* switch to tomli for parsing to match mypy dependency

* import check around toml/tomli

* add note on tomli usage

* more succinct changelog entry

* fix quotes in changelog

* linting fixes, remove unnecessary stub install

* mypy checks on mypy plugin file

* wrongly placed pragma no cover

Co-authored-by: PrettyWood <em.jolibois@gmail.com>
2021-09-05 11:25:47 +02:00
Pax e431604654 clarify docs on validation and strict type checking (#2855)
* clarify docs on validation and strict type checking

Related: Issue#578

Co-authored-by: cknoll <unknown@exampleemail.com>
Co-authored-by: PyAntony <unknown@exampleemail.com>

* add change.md for PR#2855

* docs: explicitly specify _partial_ support

* chore: update formatting of change description

Co-authored-by: cknoll <unknown@exampleemail.com>
2021-09-04 19:58:47 +02:00
Pax 4ac2501477 mention 3.8 requirement in contrib docs (#2856)
* mention 3.8 requirement in contrib docs

* add change.md for PR#2856

* docs: fix grammar and wording
2021-09-04 19:55:40 +02:00
Eric Jolibois f9c65c5b88 fix: add/fix BaseConfig type annotations (#2720) 2021-09-04 04:13:20 +02:00