Commit Graph

87 Commits

Author SHA1 Message Date
Samuel Colvin a57346ac49 Move to ruff for linting (#4709)
* WIP to move to ruff for linting

* add extend-select, fix string
2022-11-03 13:45:34 +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
Samuel Colvin f7ff485fd7 use released version of 3.11 (#4661) 2022-10-27 12:48:55 +00:00
Sviatoslav Sydorenko da7e6f89a7 Introduce a gate/check GHA job (#4615)
* Introduce a gate/check GHA job

This adds a GHA job that reliably determines if all the required
dependencies have succeeded or not.

It also allows to reduce the list of required branch protection CI
statuses to just one — `check`. This reduces the maintenance burden
by a lot and have been battle-tested across a small bunch of projects
in its action form and in-house implementations of other people.

It is now in use in aiohttp (and other aio-libs projects), CherryPy,
attrs, coveragepy, some of the Ansible repositories, pip-tools,
spaceship-prompt, all of the jaraco's projects (like `setuptools`,
`importlib_metadata`), some PyCQA, PyCA, PyPA and pytest projects, a
few AWS Labs projects.

The story behind this is explained in more detail at
https://github.com/marketplace/actions/alls-green#why.

* Stop allowing `test-old-mypy` to fail

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

* Fix a typo in "commend"

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2022-10-20 07:55:05 +01:00
dependabot[bot] 12158b8943 build(deps): bump actions/checkout from 2 to 3 (#4579)
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>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-07 09:10:24 +02:00
dependabot[bot] bb9b9a4c4b build(deps): bump carloscastrojumo/github-cherry-pick-action (#4580)
Bumps [carloscastrojumo/github-cherry-pick-action](https://github.com/carloscastrojumo/github-cherry-pick-action) from 1.0.1 to 1.0.3.
- [Release notes](https://github.com/carloscastrojumo/github-cherry-pick-action/releases)
- [Commits](https://github.com/carloscastrojumo/github-cherry-pick-action/compare/v1.0.1...v1.0.3)

---
updated-dependencies:
- dependency-name: carloscastrojumo/github-cherry-pick-action
  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-10-07 09:09:23 +02:00
Samuel Colvin 1a5b56e1b2 lower coverage threshold during V2 development 2022-09-24 21:18:19 +01:00
Samuel Colvin 80f016ecd6 add label when cherry-picking 2022-09-20 18:38:33 +01:00
Samuel Colvin 7d5ba748a4 tweak cherry-pick.yml action 2022-09-20 18:32:56 +01:00
Samuel Colvin e4a0561dbc add github token to cherry-pick 2022-09-20 14:50:46 +01:00
Samuel Colvin 2e834fecfb add cherry-pick action 2022-09-20 14:21:16 +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 f708c32f89 avoid docs update on pre-release (#4429) 2022-08-24 12:27:50 +01:00
Samuel Colvin 0bbb8747d6 fix badge links and coverage title (#4416) 2022-08-22 14:52:28 +01:00
Hasan Ramezani abcf81ec10 Rename master to main (#4405) 2022-08-19 18:49:13 +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
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
Samuel Colvin 4fb872ef3a Remove Label & Assign
Using https://github.com/pydantic/hooky instead
2022-08-10 18:50:18 +01:00
Hasan Ramezani 29020d2317 Test Python 3.11.0-rc.1 (#4357) 2022-08-10 10:23:14 +01:00
Samuel Colvin ea739fcb22 test another version of mypy (#4326) 2022-08-04 15:50:44 +00:00
Samuel Colvin b56c810f52 labe-assign revert pull_request_review change
comment out pull_request_review, only run the step
on pull requests
2022-08-04 16:07:34 +01:00
Samuel Colvin 9a0ae097bf allow label-assign to work with reviews 2022-08-04 15:44:25 +01:00
Samuel Colvin 5606157105 test 3.11.0-beta.5 (#4285)
waiting for actions/python-versions#180
2022-07-28 12:37:22 +01:00
Eric Jolibois 6d0aa20aa6 ci: add python 3.11.0b4 (#4267)
* ci: add python 3.11.0b4

* ignore both deprecation warnings

* handle specific tuple[()] case

`tuple` and `typing.Tuple` are now the same.
But `get_args(tuple[()]) == get_args(tuple) == ()`
even though `get_args(tuple[()]).__args__ = ()` and `tuple.__args__` is not defined.

* Handle type properly

Since `type` and `Type` are now the same, it triggers `_generic_get_args`
in our custom `get_args`

```py
if hasattr(tp, '_nparams'):
    return (Any,) * tp._nparams
```

So we have `class_ is Any` for generic `type` type

* Handle enum in schemas

Enums have now a (huge) doc generated by inspect.getdoc.
It's very verbose and doesn't add anything.
I reckon it's best to keep the old generic description unless
a specific doc is provided (a test exists for this)

* add test that fails with python 3.9+

* fix test for python 3.11

* fix cython
2022-07-27 10:11:19 +01:00
Hasan Ramezani 6ceff2eea2 Add Pyupgrade (#4214) 2022-07-06 08:52:01 +02:00
Hasan Ramezani 5e959720e3 Add Hasan Ramezani(hramezani) to label-assign workflow reviewers (#4207) 2022-07-04 18:53:47 +01:00
dependabot[bot] 51e056e832 build(deps): bump actions/setup-python from 3 to 4 (#4196)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)

---
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-07-03 15:45:31 +02:00
Samuel Colvin 9baec86270 try speeding up ci using caching and rearranging jobs (#3974)
* try speeding up ci using caching and rearranging jobs

* fix job references

* cache lint and docs install

* tweak caching

* tweak caching to avoid conflicts

* correct use of runner.os

* bump

* stop skipping steps depending on cache

* prevent hypothesis flakeyness

* try skipping install steps again

* remove skipping install :-(
2022-05-14 15:32:53 +01:00
Samuel Colvin b246bc6859 update mypy ci (#4073)
* update mypy ci

* test against older mypy
2022-05-14 12:31:29 +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] d128f45077 build(deps): bump actions/download-artifact from 2 to 3 (#4034)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  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-05-11 18:00:51 +01:00
dependabot[bot] b826ff65ec build(deps): bump actions/upload-artifact from 2 to 3 (#4035)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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-05-11 18:00:41 +01:00
Eric Jolibois 5490ad5173 fix: Config.copy_on_model_validation does a deep copy and not a shallow one (#3642)
* fix: `Config.copy_on_model_validation` does a deep copy and not a shallow one

closes #3641

* fix: typo

* use python 3.10 to run fastapi tests

* fix fastapi test call

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2022-05-11 17:03:48 +01:00
Samuel Colvin 8997cc5961 Remove benchmarks completely (#3973)
* removing benchmarks completely

* [no ci] add change
2022-04-04 13:29:17 +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] 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
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 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
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
Marcin Bachry a6692d177b Build Python 3.10 wheels (#3539) 2021-12-18 23:43:22 +00:00
Samuel Colvin d36bb74e83 generate x86_64 and arm64 binaries to support MacOS M1 CPU (#3514)
* generate x86_64 and arm64 binaries for macos

* Uncomment check
2021-12-12 00:13:48 +00:00
Eric Jolibois 1b1ec08f1e ci: bump to python 3.10 stable release (#3364) 2021-10-27 01:24:07 +02:00
Eric Jolibois 18e1361e8b chore(ci): switch to 3.10.0-rc2 (#3199) 2021-09-10 13:48:55 +02:00
Eric Jolibois 796a7531cd chore(deps): bump requirements (#3166)
* chore(deps): bump requirements

* chore(deps-dev): bump lint requirements

* chore(deps-dev): add test requirements

* chore(deps-dev): last bumps

* fix: mypy update

* chore: docs bumps
2021-09-03 23:47:51 +02:00
Eric Jolibois 21d002ec6e chore(ci): update to python 3.10.0-rc.1 (#3085)
* refactor: rename `is_union` into `is_union_origin`

* fix: "new" union and generic types are not the same as `typing.GenericAlias`

* chore: rename param

* fix(ci): name changed for 3.10

* fix: mypy
2021-09-03 22:56:11 +02:00