Commit Graph

537 Commits

Author SHA1 Message Date
Evorage 5cbfcba510 Trivial Markdown Fix (#4711) 2022-11-03 11:42:13 +00:00
Samuel Colvin 594effa279 Switching to pydantic_core (#4516)
* working on core schema generation

* adapting main.py

* getting tests to run

* fix tests

* disable pyright, fix mypy

* moving to class-based model generation

* working on validators

* change how models are created

* start fixing test_main.py

* fixing mypy

* SelfType

* recursive models working, more tests fixed

* fix tests on <3.10

* get docs build to pass

* starting to cleanup types.py

* starting works on custom types

* working on using annotated-types

* using annoated types for constraints

* lots of cleanup, fixing network tests

* network tests passing 🎉

* working on types

* working on types and cleanup

* fixing UUID type, restructing again

* more types and newer pydantic-core

* working on Iterable

* more test_types tests

* support newer pydantic-core, fixing more test_types.py

* working through more test_types.py

* test_types.py at last passing locally 🎉

* fixing more tests in test_types.py

* fix datetime_parse tests and linting

* get tests running again, rename to test_datetime.py

* renaming internal modules

* working through mypy errors

* fixing mypy

* refactoring _generate_schema.py

* test_main.py passing

* uprev deps

* fix conftest and linting?

* importing Annotated

* ltining

* import Annotated from typing_extensions

* fixing 3.7 compatibility

* fixing tests on 3.9

* fix linting

* fixing SecretField and 3.9 tests

* customising get_type_hints

* ignore warnings on 3.11

* spliting repr out of utils

* removing unused bits of _repr, fix tests for 3.7

* more cleanup, removing many type aliases

* clean up repr

* support namedtuples and typeddicts

* test is_union

* removing errors, uprev pydantic-core

* fix tests on 3.8

* fixing private attributes and model_post_init

* renaming and cleanup

* remove unnecessary PydanticMetadata inheritance

* fixing forward refs and mypy tests

* fix signatures, change how xfail works

* revert mypy tests to 3.7 syntax

* correct model title

* try to fix tests

* fixing ClassVar forward refs

* uprev pydantic-core, new error format

* add "force" argument to model_rebuild

* Apply suggestions from code review

Suggestions from @tiangolo and @hramezani 🙏

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>

* more suggestions from @tiangolo

* extra -> json_schema_extra on Field

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-11-02 12:01:17 +00:00
Mòrian 5dd9b4f5ca Add postgresql+psycopg as allowed scheme for PostgreDsn (#4689) (#4690) 2022-10-31 10:37:57 +00:00
chaojie 02d4e18839 Docs add awesome-pydantic (#4616) 2022-10-17 16:02:17 +01:00
Rémy HUBSCHER 0a6e413866 Add missing typing to example (#4596)
* Add missing typing to example

* Update example typing.
2022-10-10 13:36:03 +02:00
Zach Kirsch a44d373f1f Fix "trough" typo in Model Config docs (#4593) 2022-10-07 09:15:47 +02:00
Miloš Mandić c22fe9a8f3 v2 docs broken link fix (#4533)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-09-21 21:40:07 +02:00
Samuel Colvin e071a3e368 remove repeat newline in docs (again) (#4545) 2022-09-20 14:19:33 +00:00
Samuel Colvin c3e3fafae0 remove repeat newline in docs (#4544) 2022-09-20 14:01:22 +00:00
Samuel Colvin e0b8e0530b tiny tweak to docs (#4543) 2022-09-20 14:48:59 +01:00
Dmitry Lavrentev 996101b8ba fix: missing file extension in model_config.md link (#4512) 2022-09-13 09:39:31 +02:00
Samuel Colvin 85e4596958 Move settings to pydantic-settings (#4492)
* Move settings to pydantic-settings

* fix docs, remove dotenv

* fix coverage

* removing unused test fixture
2022-09-07 13:05:51 +01:00
Samuel Colvin f341049b9e Remove Cython & Move to pyproject.toml (#4473)
* Remove Cython

* fix CI

* fix coverage

* fix tests

* switching to pypyroject.toml

* pre-commit all and use pre-commit for linting

* no mypy tests on macos and windows on ci, use flake8-pyproject

* fix docs and tests CI

* check build is working

* drop pytest-cov

* window and macos ci with 3.11, reduce filtering

* use pip-tools to pin all dependencies

* fix docs and fastapi tests

* fix test deps for 3.7

* no cache on tests job

* revert fastapi changes, fix coverage

* fix mypy coverage

* test with older mypy

* dotenv not required for mypy tests

* split testing requirements std and extra

* typo

* @PrettyWood comments

* correct branch name

* mypy python_version and pr template
2022-09-06 17:15:51 +01:00
Samuel Colvin a4367c1c58 Revert percent encoding in URLs. (#4470)
* Revert "Fix `AnyUrl.build` doesn't do percent encoding (#3061) (#4224)"

This reverts commit e34ff9255f.

* change and warning
2022-09-05 11:02:43 +01:00
dependabot[bot] 2add8a9482 build(deps): bump hypothesis from 6.54.3 to 6.54.4 (#4464)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.54.3 to 6.54.4.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.54.3...hypothesis-python-6.54.4)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 23:49:06 +02:00
dependabot[bot] f1fb4f20b4 build(deps): bump mkdocs-material from 8.4.0 to 8.4.2 (#4463)
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.4.0 to 8.4.2.
- [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.4.0...8.4.2)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 23:48:47 +02:00
dependabot[bot] 85cd9ff5d1 build(deps): bump autoflake from 1.4 to 1.5.3 (#4462)
Bumps [autoflake](https://github.com/PyCQA/autoflake) from 1.4 to 1.5.3.
- [Release notes](https://github.com/PyCQA/autoflake/releases)
- [Commits](https://github.com/PyCQA/autoflake/compare/v1.4...v1.5.3)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 23:48:25 +02:00
Samuel Colvin b065908490 fix type hints in BaseSettings.Config (#4450)
* fix type hints in BaseSettings.Config

* add tests and change notice
2022-08-30 13:08:23 +01:00
Samuel Colvin 4832ae9acd add Explosion AI and AWS to sponsors (#4413)
* add Explosion AI and AWS to sponsors

* rename "Explosion AI" to "Explosion"

Co-authored-by: Ines Montani <ines@ines.io>

Co-authored-by: Ines Montani <ines@ines.io>
2022-08-23 10:29:36 +00:00
Grant Murray 9d2e1c40cb patch/typo-in-pydantic-v2-docs (#4422)
Change a single word in the Pydantic v2 documentation (should be `unchanged`, no?)
2022-08-23 09:41:58 +02:00
Samuel Colvin dd5f2a55aa fix links 2022-08-22 22:32:56 +01:00
Samuel Colvin 5b2bcfd73c correct copy_on_model_validation docs (#4420)
* correct "copy_on_model_validation" docs, fix #4369

* Update docs/usage/model_config.md

* correct docs
2022-08-22 22:00:18 +01:00
Anthony Miyaguchi fe7c9da6c1 Fix #1458 - Allow for custom parsing of environment variables via parse_env_var in Config object (#4406)
* Fix #1458 - Allow for custom parsing of environment variables via env_parse

* Add docs for env_parse usage

* Add changes file for #3977

* fixup: remove stray print statement

* Revert env_parse property on field

* Add parse_env_var classmethod in nested Config

* Update documentation for parse_env_var

* Update changes file.

* fixup: linting in example

* Rebase and remove quotes around imported example

* fix example

* my suggestions

* remove unnecessary Field(env_parse=_parse_custom_dict)

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-22 16:06:14 +00:00
Sebastián Ramírez 8dade7e9ac Add JSON-compatible float constraints for NaN and Inf (#3994)
*  Add JSON-compatible float constraints for NaN and Inf

* switching to a single "allow_inf_nan"

* fix tests

* add change and docs

* add allow_inf_nan to Config

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-22 15:21:56 +01:00
Hasan Ramezani abcf81ec10 Rename master to main (#4405) 2022-08-19 18:49:13 +01:00
dependabot[bot] 4c37e662e3 build(deps): bump hypothesis from 6.54.1 to 6.54.3 (#4403)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.54.1 to 6.54.3.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.54.1...hypothesis-python-6.54.3)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-19 10:27:30 +00:00
dependabot[bot] 98a35fdb18 build(deps): bump mkdocs-material from 8.3.9 to 8.4.0 (#4401)
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.3.9 to 8.4.0.
- [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.3.9...8.4.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-19 10:11:08 +00:00
Fares Ahmed e34ff9255f Fix AnyUrl.build doesn't do percent encoding (#3061) (#4224)
* Fix `AnyUrl.build` doesn't do percent encoding (#3061)

please review

* Use `urllib.parse` instead of custom implementation for percent encoding

* Make `quote_plus` a `stricturl` option

* Add docs for `stricturl(quote_plus=True)`

* Better changes message for #3061

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

* Fix precent encoding version note to V1.10

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

* Fix `Building URLs` snippit markdown

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

* Fix formatting for `docs/examples/types_url_building.py`

* fix docs

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-19 09:20:20 +00:00
commonism 78e84b92c0 update links to https://github.com/pydantic/… (#4398)
Co-authored-by: Markus Koetter <koetter@cispa.de>
2022-08-19 07:46:58 +01:00
Samuel Colvin 2f883b9509 fix pattern matching version, ref #3921 (#4384) 2022-08-16 22:29:59 +01:00
rafael 7344374dd0 BaseModel: Document and test structural pattern matching (#3921)
* BaseModel: Add __match_args__ attribute to namespace

* changelog

* amend docs

* add tests

* Update changes/3920-irgolic.md

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

* Update .github/workflows/ci.yml

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

* rename test_match => test_structural_pattern_matching

* pytest.skip => pytest.mark.skipif

* Revert "BaseModel: Add __match_args__ attribute to namespace"

This reverts commit 79367356fddac90b047b10620dc895425ec25b40.

* adjust tests for kwarg only structural pattern matching

* adjust docs for kwarg only pattern matching

* changes: Support => Document

* fix docs?

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2022-08-16 08:47:17 +02:00
Hasan Ramezani 4e7878932c Update Python version in contributing doc (#4376) 2022-08-14 20:57:03 +00:00
Hasan Ramezani c5d57b7cf5 Fix the behavior change in .json() documentation (#4371)
* Fix the behavior change in `.json()` documentation

* Add breaking change to original change in HISTORY.md
2022-08-14 17:46:24 +00:00
Samuel Colvin cc68900274 Build binaries for Python 3.11 (#4374)
* build binaries for python 3.11

* add change

* [skip ci] revert CI if comment

* add 3.11 to pypi classifiers
2022-08-14 18:32:33 +01:00
Arseny Boykov c24d33e5f1 Generate docs exampels for Python 3.10 and above (#4339)
* Generate docs exampels for Python 3.10 and above

Code quality is not great and main intent here is to show the result.

* Fix docs build on 3.9

* Build docs on 3.10

* What's Python 3.1?

* Create temp dir if not exists

* Refactor and improve imlementetion

* Keep runtime typing in examples

* Revert unrelated formatting changes

* Add changes file

* Allow specifying requirements in examples

* Pin autoflake and pyupgrade

* Add docs/build to Makefile lint/format/mypy

* ignore_missing_imports for ansi2html and devtools

* Add .tmp-projections to .gitignore

* Remove dont-upgrade now when Pattern is supported

* Update postponed evaluation examples

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-14 17:21:53 +01:00
hottwaj cdd091c8ac Initial implementation of ConstrainedDate, condate (#3740)
* Initial implmenetation of ConstrainedDate, condate, with tests and docs

* Attempt at fixing hypothesis tests for ConstrainedDate.  Suspect still not working

* removed forgotten breakpoint() :(

* suggested changes to pydantic/_hypothesis_plugin.py for condate etc

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>

* - fixed import for hypothesis tests

* - linting fixes only

* - more fixes for linting

* changes following review by samuelcolvin 2022-08-08.  Will rebase next

* - added changes to changes file

* fixed changes file filename to PR #3740

* additional changes requested by samuelcolvin 2022-08-11: add test for schema_json, add hypothesis test, etc

* make test_json_schema compare to a dictionary rather than json string

* added test_date_constrained_types to test_schema

* rewrite tests

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-12 14:37:41 +00:00
Kyungmin Lee 0320a99361 feat: add support multiple dotenv files (#1497) (#3222)
* feat: support multiple dotenv files

Allow BaseSettings to accept multiple dotenv files in Config as a list
or tuple.

* docs: add multiple dotenv support

* docs: add a change summary

* test: add missing tests

* fix: test coverage

* refactor: raise a TypeError when an object of an invalid type is passed

* fix: a lint error

* refactor: remove `_read_process_env_vars` method

* docs: update priority

* refactor: apply a review

* test: simplify testing

* refactor: apply reviews

* reverse piority order, reduce diff size

* fix change file grammar

* correct docs, avoid unnecessary copy of os.environ

* correct wording in docs

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-12 12:17:01 +00:00
Samuel Colvin 47362e33b6 Pick 1.9 (#4350)
* generate history from changes, uprev

* Pydantic V2 blog (#4218)

* first draft of pydantic V2 blog

* more blog

* blog rendering and formatting

* more section

* completing conversion table

* prompt build

* reviewing blog post

* more reviewing and extending

* recommendations from @Rabscuttler and @PrettyWood

* add implementation details and more suggestions

* comment about breaking changes

* convert namespae to table, more removals

* Apply suggestions from code review by @tiangolo

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>

* feedback from @tiangolo's review

* changes from @adriangb's review

* Apply suggestions from code review

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>

* convert namespace info to psuedo-code

* rename property, remove schema_json()

* adding validation context

* remove 'model_schema_json', take 2

* more tweaks while reviewing

* comment about pypy and tagged unions

* add thanks :prey:, prepare for release

* suggestions from @PrettyWood

* suggestions from @PrettyWood, model_dump_json comment

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>

* comments mostly from @PrettyWood (#4226)

* comments mostly from @PrettyWood

* add updated comment

* fix pre-commit

* allow for shallow copies (#4093)

* allow for shallow copies

* Add changes file

* tweak change

* update for comments

* rename attr

* use single quotes

* bump ci

* add warning if not a string, switch to string literals

* fix linting, prompt ci

* fix ci

* extend and fix tests

* change default to "shallow"

Co-authored-by: Samuel Colvin <s@muelcolvin.com>

* uprev and prepare for release

* linting

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Co-authored-by: Tim Paine <t.paine154@gmail.com>
2022-08-12 11:09:49 +01:00
Samuel Colvin 5c8942bdd4 Revert "Add nested json encoding (#3941)" (#4367)
This reverts commit b42fae081c.
2022-08-12 11:08:33 +01:00
Hasan Ramezani 697459a73d Change path in validation_decorator_types example to a relative path (#4341)
* Change path in validation_decorator_types example to a relative path

* make the example a little clearer

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-09 11:12:05 +00:00
Arseny Boykov 0500610ec5 Typecheck Json inner type (#4332)
* Add .venv/ to .gitignore

* Allow typecheckers to infer Json inner type

* Fix and improve mypy tests

* Add type tests

* Add Json[Any] case to schema test

* Update example in docs

* Add changes file

* Use <3.9 compatible annotations for tests
2022-08-09 11:49:27 +01:00
Hasan Ramezani a9c273235f Fix sub-model link in usage/models docs (#4234) 2022-08-09 10:51:52 +01:00
Gustavo Satheler d90def3c4e Add to upper function for strings and bytes (#4165)
* feat: add to upper function for strings and bytes

* docs(changes): add message for change

* fix: add constr upper on types

* fix: add constr upper on types

* feat: add examples and doc usage

* test: add test to upper for types

* chore: apply suggestions from code review

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* chore(docs): reorder `anystr_upper` to under `anystr_lower`

* fix(test): adjust parametrizes to constrained bytes upper

* refactor: use pytest parametrize for unify test constrained str upper

* refactor: use pytest parametrize for unify test constrained str lower

* refactor(test): use pytest parametrize for unify test any str upper

* refactor(test): use pytest parametrize for unify test any str lower

* refactor(test): use pytest parametrize for unify test constrained bytes lower

* refactor(test): use pytest parametrize for unify test any str strip whitespace

* refactor(test): change test signatures to improve readability

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-08-08 17:06:00 +01:00
Amin Alaee 65a1381591 Fix schema for set and frozenset with default value (#4155)
* Fix schema for Set with default value

* add changelog

* Add frozenset to schema mapping docs
2022-08-08 17:02:04 +01:00
Lily Wang b42fae081c Add nested json encoding (#3941)
* add nested json encoding

* fix timezones

* add changes doc

* split tests and rename example

* Update changes/3941-lilyminium.md

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

* split tests into functions

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-08 15:46:51 +00:00
Tiemo cf16f7c388 Add CockroachDsn type (#3830)
* Add CockroachDsn type

The CockroachDsn type supports the following dialects: cockroachdb,
cockroachdb+psycopg2 and cockroachdb+asyncpg. It's meant to be used in
conjunction with the cockroachdb sqlalchemy dialect, more information
can be found here:
https://github.com/cockroachdb/sqlalchemy-cockroachdb

* tweak change log

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-08 15:14:35 +00:00
gieddy660 9599a3d256 updates to description of the fields option. (#3822)
* updates to description of the fields option.

Update of the fields option for config to reflect the fact that it is not actually equivalent to the Field class, as I was having troubles understanting ehy I couldn't set default or default_factory.

* corrected typo

* correction

* fix typo

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-08 14:53:43 +00:00
Mateo Aguirre Duque 7431683e88 Alias support in decorator validate_arguments (#3019)
* add support for alias handling in validate_arguments

* add test for alias handling in validate_arguments

* add documentation on alias support for decorator

* bug fixed in the validate_argumen decorator documentation

* add changes README

* change in the documentation due to a drafting error

* Update changes/3019-MAD-py.md

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

* more challenging tests

* run the format checker

* integration of empty string as alias

Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-08 13:33:51 +01:00
Yasser Tahiri e07d73b373 Update URLs after migrating to organization (#4348)
* update URLs

* add a change file
2022-08-08 12:27:35 +00:00
Luca Repetti 460f858cc5 Add mypy static checking for default and default_factory (#3430)
* Add static checking for default and default_factory

* Describe PR change

* Remove unnecessary booleans default_specified and default_factory_specified

* Add test with default without Field

* Apply suggestions from code review

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

* Fix tests

* Add handling of Overload types for mypy0.971

* Avoid to use walrus operator

* Support mypy 0.910 for overloaded types

* Increase coverage for mypy plugin

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-08-08 13:07:23 +01:00