Commit Graph

1222 Commits

Author SHA1 Message Date
Stefan Scherfke 36c53ceaa3 Fix pytest crashes with hypothesis and pydantic (#3727)
Pytest (sometimes?) crashes when it is invoked with `-vv` and pydantic and hypthesis are installed.

This is because `_registered(typ)` modifies `_DEFINED_TYPES` while it is being iterated:

```
INTERNALERROR>   File ".../lib/python3.9/site-packages/pydantic/_hypothesis_plugin.py", line 361, in <module>
INTERNALERROR>     for typ in pydantic.types._DEFINED_TYPES:
INTERNALERROR>   File ".../lib/python3.9/_weakrefset.py", line 65, in __iter__
INTERNALERROR>     for itemref in self.data:
INTERNALERROR> RuntimeError: Set changed size during iteration
```
2022-04-02 15:11:48 +01:00
dependabot[bot] f96a6131a3 build(deps): bump mypy from 0.931 to 0.942 (#3968)
* build(deps): bump mypy from 0.931 to 0.942

Bumps [mypy](https://github.com/python/mypy) from 0.931 to 0.942.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.931...v0.942)

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

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

* build(deps): bump mypy from 0.931 to 0.942

Bumps [mypy](https://github.com/python/mypy) from 0.931 to 0.942.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.931...v0.942)

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

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

* fix mypy

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-04-02 14:50:07 +01:00
Samuel Colvin f0acf6efe7 Prevent subclasses of bytes being converted to bytes (#3707)
* adding a test

* fix and add change description
2022-04-02 14:45:31 +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
Wong Hoi Sing Edison 6e0f81c73f CentOS 7: read_text(encoding='utf-8') (#3625)
With CentOS 7 Python 3.6, running install from source with pip failed:

    sudo podman run -ti --rm centos:7
    yum -y update
    yum -y install epel-release
    yum -y install git python3 python3-devel python3-pip python3-setuptools python3-wheel
    git clone https://github.com/samuelcolvin/pydantic.git
    cd pydantic
    pip3 install .

With following error message:

    [root@c99d0585636c pydantic]# pip3 install .
    Processing /pydantic
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-91v_ixvz-build/setup.py", line 62, in <module>
            history = (THIS_DIR / 'HISTORY.md').read_text()
          File "/usr/lib64/python3.6/pathlib.py", line 1197, in read_text
            return f.read()
          File "/usr/lib64/python3.6/encodings/ascii.py", line 26, in decode
            return codecs.ascii_decode(input, self.errors)[0]
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14648: ordinal not in range(128)

        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-91v_ixvz-build/

This PR add the required `read_text(encoding='utf-8')` for `setup.py`.

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
2022-04-02 14:05:12 +01:00
Samuel Colvin df8b2e100f Combine dependabot prs (#3969)
* allow combining of dependabot PRs

* add combine-dependabot.yml
2022-04-02 13:44:30 +01:00
dependabot[bot] 7c05a61e4a build(deps): bump pytest-mock from 3.6.1 to 3.7.0 (#3967)
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.6.1 to 3.7.0.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases)
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.6.1...v3.7.0)

---
updated-dependencies:
- dependency-name: pytest-mock
  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 13:25:58 +01:00
dependabot[bot] b785f87aea build(deps): bump typing-extensions from 4.0.1 to 4.1.1 (#3874)
Bumps [typing-extensions](https://github.com/python/typing) from 4.0.1 to 4.1.1.
- [Release notes](https://github.com/python/typing/releases)
- [Changelog](https://github.com/python/typing/blob/master/typing_extensions/CHANGELOG)
- [Commits](https://github.com/python/typing/compare/4.0.1...4.1.1)

---
updated-dependencies:
- dependency-name: typing-extensions
  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 13:25:51 +01:00
dependabot[bot] 9d29aabb9c build(deps): bump cython from 0.29.26 to 0.29.28 (#3871)
Bumps [cython](https://github.com/cython/cython) from 0.29.26 to 0.29.28.
- [Release notes](https://github.com/cython/cython/releases)
- [Changelog](https://github.com/cython/cython/blob/master/CHANGES.rst)
- [Commits](https://github.com/cython/cython/compare/0.29.26...0.29.28)

---
updated-dependencies:
- dependency-name: cython
  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-04-02 13:25:43 +01:00
dependabot[bot] c12382d00f build(deps): bump twine from 3.7.1 to 4.0.0 (#3965)
Bumps [twine](https://github.com/pypa/twine) from 3.7.1 to 4.0.0.
- [Release notes](https://github.com/pypa/twine/releases)
- [Changelog](https://github.com/pypa/twine/blob/main/docs/changelog.rst)
- [Commits](https://github.com/pypa/twine/compare/3.7.1...4.0.0)

---
updated-dependencies:
- dependency-name: twine
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-02 08:57:22 +01:00
dependabot[bot] d8054380d3 build(deps): bump pytest from 6.2.5 to 7.1.1 (#3926)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.1.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.1.1)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-02 08:57:08 +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] 29b8052e4e build(deps): bump python-dotenv from 0.19.2 to 0.20.0 (#3963)
Bumps [python-dotenv](https://github.com/theskumar/python-dotenv) from 0.19.2 to 0.20.0.
- [Release notes](https://github.com/theskumar/python-dotenv/releases)
- [Changelog](https://github.com/theskumar/python-dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/theskumar/python-dotenv/compare/v0.19.2...v0.20.0)

---
updated-dependencies:
- dependency-name: python-dotenv
  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:28 +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] d7a8272d7e build(deps): bump mypy from 0.930 to 0.931 (#3656)
Bumps [mypy](https://github.com/python/mypy) from 0.930 to 0.931.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.930...v0.931)

---
updated-dependencies:
- dependency-name: mypy
  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 23:30:57 +00:00
dependabot[bot] 9967f0ebe3 build(deps): bump pre-commit from 2.16.0 to 2.17.0 (#3731)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.16.0 to 2.17.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.16.0...v2.17.0)

---
updated-dependencies:
- dependency-name: pre-commit
  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:37:59 +00:00
Gin Cui f3f2408e2d Fixed a typo in decimal_encoder's doc. (#3820) 2022-03-01 22:37:09 +00:00
dependabot[bot] b90e128175 build(deps): bump coverage from 6.2 to 6.3.2 (#3839)
Bumps [coverage](https://github.com/nedbat/coveragepy) from 6.2 to 6.3.2.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](https://github.com/nedbat/coveragepy/compare/6.2...6.3.2)

---
updated-dependencies:
- dependency-name: coverage
  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:35:04 +00: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
dependabot[bot] 2b0d4d90eb build(deps): bump actions/checkout from 2 to 3 (#3869)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-01 22:33:43 +00:00
dependabot[bot] 2c980eaf60 build(deps): bump actions/setup-python from 2 to 3 (#3868)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 3.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-01 22:33:04 +00:00
Eric Jolibois 9d631a3429 fix(ci): update fastapi tests (#3690)
* use python 3.10 to run fastapi tests

* fix fastapi test call
2022-01-17 22:30:39 +01: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 fbf8002cef prepare for v1.9.0 release, extra change 2021-12-31 15:02:06 +00:00
Samuel Colvin 5406423268 prepare for v1.9.0 release 2021-12-31 14:53:14 +00:00
Samuel Colvin 87da9ac23f apply update_forward_refs to json_encoders (#3595)
* apply update_forward_refs to json_encoders, fix #3583

* linting

* mypy

* avoid use of ForwardRef with python3.6

* fix ForwardRef usage, take 2

* coverage
2021-12-31 14:44:09 +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 8ef492b85f build(deps): bump mypy from 0.920 to 0.930 (#3573)
* build(deps): bump mypy from 0.920 to 0.930

* fix: avoid mypy plugin crash

Due to https://github.com/python/mypy/pull/11332, mypy would crash
because `__builtins__` is not part of `ctx.api` modules, `builtins` is

* fix tests
2021-12-29 16:51:35 +00:00
Samuel Colvin 2d3d266d0a remove failing release step
Remove failing "upload pypi files to release" step
from deploy job, see
https://github.com/svenstaro/upload-release-action/issues/61
2021-12-29 16:39:36 +00:00
Samuel Colvin ef4678999f add step to upload pypi files to release 2021-12-24 14:07:08 +00:00
Samuel Colvin 5d6f48cb07 prepare for v1.9.0a2 2021-12-24 13:54:35 +00:00
Eric Jolibois e8822775e3 fix: support generic models with discriminated union (#3551) 2021-12-24 13:17:39 +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] e14e7561ed build(deps): bump mypy from 0.910 to 0.920 (#3552)
* build(deps): bump mypy from 0.910 to 0.920

Bumps [mypy](https://github.com/python/mypy) from 0.910 to 0.920.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.910...v0.920)

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

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

* fix mypy issues

* fix mypy issues

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
2021-12-24 13:11:05 +00:00
dependabot[bot] 5ce652bf84 build(deps): bump cython from 0.29.25 to 0.29.26 (#3553)
Bumps [cython](https://github.com/cython/cython) from 0.29.25 to 0.29.26.
- [Release notes](https://github.com/cython/cython/releases)
- [Changelog](https://github.com/cython/cython/blob/master/CHANGES.rst)
- [Commits](https://github.com/cython/cython/compare/0.29.25...0.29.26)

---
updated-dependencies:
- dependency-name: cython
  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:57 +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
Eric Jolibois fe2a5e2170 fix: smart union with typeddict (#3543) 2021-12-22 19:39:18 +00:00
Hyun Sol c532e8324e #3234 exclude extra field when represent model (#3241)
* exclude extra field when represent model

* add test code

* fix W293

* add change md

* Update changes/3234-cocolman.md

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

* Update pydantic/main.py

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

* Update tests/test_main.py

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

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2021-12-19 16:08:26 +00:00
Eric Jolibois 93faefb4a9 fix: nested ORM from nested dictionaries (#3182)
closes #3181
2021-12-19 10:41:51 +00:00
Eric Jolibois 5ad73d0388 fix: models copied via Config.copy_on_model_validation always have all fields (#3201)
Small regression in #2231.
The shallow copy done with `Config.copy_on_model_validation = True` (default behaviour)
was using excluded / included fields when it should just copy everything

closes #3195
2021-12-19 10:37:30 +00:00
layday da916f369e Remove __root__ from BaseModel typing-only attrs (#3540)
* Remove `__root__` from BaseModel typing-only attrs

`__root__` is not a class variable nor is it always present.

The switch to `ClassVar` caused type errors to be reported in Pylance/Pyright.

* Add changelog entry
2021-12-19 10:24:52 +00:00
Eric Jolibois 0f961d4595 fix link to discriminated union section 2021-12-19 09:04:19 +01:00
Marcin Bachry a6692d177b Build Python 3.10 wheels (#3539) 2021-12-18 23:43:22 +00:00
Samuel Colvin 5de27ca465 update history and uprev version 2021-12-18 21:18:37 +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