John Carter
cd8b504568
Pass model_class to schema_extra staticmethod ( #1125 )
...
* Pass model_class to schema_extra staticmethod
Resolves #1122
* Add changelog
* Apply suggestions from code review
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Fix import after rebase
* Fix test bug
* Use TypeError instead of assert as per review
* Rename var so declaration fits one one line
* tiny tweaks
Co-authored-by: Samuel Colvin <samcolvin@gmail.com >
2020-01-06 12:01:03 +00:00
Samuel Colvin
e169bd60e4
encourage use of version_info() in issues ( #1138 )
...
* encourage use of version_info() in issues
* improve grammar and add change
* switch test import
2020-01-02 19:34:33 +00:00
Samuel Colvin
31cac4783b
improve pydantic import time ( #1132 )
...
* improve pydantic import time, fix #1127 , fix #1039
* more tweaks
* tweak utils.py
* defering inspect
2020-01-02 14:35:03 +00:00
dependabot-preview[bot]
8364983545
Bump coverage from 5.0 to 5.0.1 ( #1123 )
...
Bumps [coverage](https://github.com/nedbat/coveragepy ) from 5.0 to 5.0.1.
- [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/coverage-5.0...coverage-5.0.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2020-01-02 11:45:29 +00:00
Samuel Colvin
e9da909dd3
remove explicit re-exports from __init__.py ( #1124 )
2020-01-02 11:44:48 +00:00
Koudai Aono
2b47932f8e
Fix EmailStr for Cython ( #1126 )
...
* Fix EmailStr for Cython
* add a change document.
* Fix NameEmail
* Update changes/1126-koxudaxi.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update pydantic/networks.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update changes/1126-koxudaxi.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update pydantic/networks.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
Co-authored-by: Samuel Colvin <samcolvin@gmail.com >
2019-12-26 18:15:59 +00:00
Samuel Colvin
065ae2e4c4
fix modify schema ( #1103 )
...
* modify schema, fix #1102
* remove DSN from schema table
* fix tests
* add outer_type_ to ModelField, fix coverage
* simplify ModelField._type_display
* remove debugs
* revert change to _type_display
* test fix
2019-12-21 15:46:11 +00:00
Samuel Colvin
e1ae058afb
Consistent checks for sequence like objects ( #1111 )
2019-12-20 15:08:45 +00:00
Marcus McCurdy
d63e9b64ce
Fix for Optional Json fields ( #1080 )
...
* Fixes #1073
* remove test
* fix tests
Co-authored-by: Samuel Colvin <samcolvin@gmail.com >
2019-12-20 14:04:22 +00:00
dependabot-preview[bot]
e05c2aac5f
Bump pytest from 5.3.1 to 5.3.2 ( #1100 )
...
Bumps [pytest](https://github.com/pytest-dev/pytest ) from 5.3.1 to 5.3.2.
- [Release notes](https://github.com/pytest-dev/pytest/releases )
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest/compare/5.3.1...5.3.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-12-20 13:02:08 +00:00
dependabot-preview[bot]
4fa56d9d4f
Bump coverage from 4.5.4 to 5.0 ( #1101 )
...
Bumps [coverage](https://github.com/nedbat/coveragepy ) from 4.5.4 to 5.0.
- [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/coverage-4.5.4...coverage-5.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-12-20 13:01:56 +00:00
dependabot-preview[bot]
178a23da01
Bump mypy from 0.760 to 0.761 ( #1118 )
...
Bumps [mypy](https://github.com/python/mypy ) from 0.760 to 0.761.
- [Release notes](https://github.com/python/mypy/releases )
- [Commits](https://github.com/python/mypy/compare/v0.760...v0.761 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-12-20 13:01:45 +00:00
dependabot-preview[bot]
42c4b3e3a1
Bump mypy from 0.750 to 0.760 ( #1107 )
...
Bumps [mypy](https://github.com/python/mypy ) from 0.750 to 0.760.
- [Release notes](https://github.com/python/mypy/releases )
- [Commits](https://github.com/python/mypy/compare/v0.750...v0.760 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-12-18 13:22:41 +00:00
Aviram Hassan
5510a13f6c
Added optional for root_validator to be skipped if values validation fails ( #1050 )
...
* Added optional for root_validator to be skipped if values validation fails
* cleaner usage of skip_on_failure
* skip_on_failure: documentation update
2019-12-16 11:15:06 +00:00
Samuel Colvin
bd72e80e94
Prevent type attributes being added to schema unintentionally ( #1065 )
...
* Prevent type attributes being added to schema unintentionally, fix #1064
* simpler boolean check
* change to __modify_schema__
* better docs
* Update docs/usage/schema.md
Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com >
2019-12-11 12:01:41 +00:00
Samuel Colvin
de6bd1b469
Settings config inheritance fix #1091 ( #1093 )
2019-12-11 11:58:03 +00:00
Scott P
3804998649
Trick Cython into allowing str subclassing ( #1061 )
...
* Trick Cython into allowing str subclassing
* Added a changes file
* Removed 2nd paragraph from changes file so it passes tests
* Augmented with tests for StrictInt/Float
* Removed commented out StrictBool subclass testing
2019-12-10 11:07:56 +00:00
Søren Bjerregaard Vrist
33fee6d9be
Let SecretStr/SecretBytes be value equals to them selves ( #1079 )
...
fix #1078
2019-12-09 17:23:34 +00:00
Selim Belhaouane
bdc3973d90
Allow schema_extra to be a callable ( #1054 )
...
* fixes for Windows development
* Allow Config.schema_extra to be a callable
2019-12-09 11:01:17 +00:00
Greg Lutostanski
34a64efc04
Fix schema for fields with nested None as default ( #1088 )
...
fix #1087
As None is typically used for the default value, it is not usually
encoded on its own into schemas. There was an issue, where using None
not as the top-level value, but rather inside other objects (e.g.
[None]) will throw a Traceback.
2019-12-09 10:05:55 +00:00
dependabot-preview[bot]
3891b1cbc0
Bump pytest-mock from 1.12.1 to 1.13.0 ( #1083 )
...
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock ) from 1.12.1 to 1.13.0.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases )
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v1.12.1...v1.13.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-12-06 11:38:44 +00:00
Sebastián Ramírez
ea709cc66f
Add FastAPI tests to Pydantic's CI tests ( #1075 )
...
fix #1041
* Add test-fastapi.sh script, after failing to create reusable variables in Make
* Add test-fastapi Make target
* Add fastapi dir for tests to gitignore
* Add fastapi tests to Travis
* Update test-fastapi to run the minimum (pytest)
* Move make test-fastapi to normal run, no "Without Deps"
* Install Pydantic without Cython for FastAPI tests
* Put FastAPI tests in its own Travis job
* Add PR changes description
* Remove coverage for FastAPI, it's not relevant for Pydantic
* Implement code review changes, refactor Makefile use and fastapi tests
* Add a bug intentionally, to test that FastAPI tests are using the current source
and make sure it actually breaks CI.
* Fix intentional bug. Confirmed it breaks Travis for FastAPI.
2019-12-05 11:35:56 +00:00
Samuel Colvin
9255012c08
add version_info to make creating issues easier ( #1071 )
...
* add version_info to make creating issues easier
* improve version_info()
* improve contributing docs
2019-12-04 15:14:53 +00:00
Kieran Darcy
9982eb43dd
Change BaseModel.parse_file to use Config.json_loads ( #1069 )
...
fix #1067
* Making json_loads available to parse_file
* Change BaseModel.parse_file to use Config.json_loads
* Update changes/1067-kierandarcy.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Fixed some style issues and added missing test for parse_file_as
2019-12-03 15:05:27 +00:00
dmontagu
d538df5fbb
Update for compatibility with mypy 0.750 ( #1058 )
...
* Update for compatibility with mypy 0.750
* Remove coverage checks for 0.740 compatibility
2019-12-02 13:09:37 +00:00
Aviram Hassan
1b9f08bead
Dataclass is now compatible with schema methods ( #1045 )
2019-12-02 12:44:21 +00:00
Samuel Colvin
151143deb4
coverage for UndefinedType
2019-11-28 18:28:51 +00:00
Samuel Colvin
b521f6b24a
prepare v1.2 ( #1042 )
...
* making field-reuse idempotent (#1016 )
* making field-reuse idempotent
* fix for 3.6
* correct change details
* uprev
* generate HISTORY.md
2019-11-28 17:46:43 +00:00
Sebastián Ramírez
d9bbb05a16
Implement Optional required ( #1031 )
...
* Implement Optional required, when creating a ModelField(required=True), make it persist
* Add test for nullable required
* Improve formatting of Undefined custom object
* Refactor field infer/creation with Undefined to make it idempotent
Needed for when _type_analysis is re-run in Generics
* Add PR changes
* Increment/update tests with code review
* Update/refactor Undefined implementation with code review
* Fix BoolUndefined as string type for mypy, not runtime
* Add docs about required Optional
* Add explicit tests for Any
* Apply code review requested changes
* move tests out of test_validators.py
2019-11-28 16:48:33 +00:00
dependabot-preview[bot]
cb82d3c74b
Bump pytest from 5.3.0 to 5.3.1 ( #1036 )
...
* Bump pytest from 5.3.0 to 5.3.1
Bumps [pytest](https://github.com/pytest-dev/pytest ) from 5.3.0 to 5.3.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases )
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest/compare/5.3.0...5.3.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
* combine uprevs
2019-11-28 11:49:07 +00:00
dmontagu
c71326d4a6
Add better support for validator reuse ( #941 )
...
* Add better support for validator reuse
* Clean up classmethod unpacking
* Add changes
* Fix coverage check
* Make 3.8 compatible
* Update changes/940-dmontagu.md
Co-Authored-By: Samuel Colvin <s@muelcolvin.com >
* Make allow_reuse discoverable by adding to error message
* switch _check_validator_name to _prepare_validator
2019-11-25 15:15:05 +00:00
dmontagu
6564bbb4ce
Add parse_as_type function ( #934 )
...
* Add parse_as_type function
* Add changes
* Incorporate feedback
* Add naming tests
* Fix double quotes
* Fix docs example
* Reorder parameters; add dataclass and mapping tests
* Rename parse_as_type to parse_obj, and add parse_file
* Incorporate feedback
* Incorporate feedback
* use custom root types
2019-11-25 12:55:15 +00:00
dmontagu
62bc930f57
Add support for mapping types as custom root ( #958 )
...
* Add support for mapping types as custom root
* Incorporate feedback
* Add changes
* Incorporate feedback
* Add docs and tests
* Fix linting issue
* Incorporate more feedback
* Add more specific match
2019-11-25 12:19:41 +00:00
dmontagu
643266944c
Support typing.Literal in python 3.8 ( #1027 )
...
* Support typing.Literal in python 3.8
* Improve import pattern for Literal
* Update references to in docs
* Try to get build to pass
2019-11-25 11:32:01 +00:00
dependabot-preview[bot]
796b9588c6
Bump twine from 3.0.0 to 3.1.0 ( #1029 )
...
Bumps [twine](https://github.com/pypa/twine ) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/pypa/twine/releases )
- [Changelog](https://github.com/pypa/twine/blob/master/docs/changelog.rst )
- [Commits](https://github.com/pypa/twine/compare/3.0.0...3.1.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-11-25 09:13:34 +00:00
Samuel Colvin
4e23d4a61f
__str__ and __repr__ inheritance for models, fix #1022 ( #1023 )
2019-11-22 15:29:56 +00:00
dependabot-preview[bot]
95a7aa6021
Bump pytest-mock from 1.12.0 to 1.12.1 ( #1018 )
...
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock ) from 1.12.0 to 1.12.1.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases )
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v1.12.0...v1.12.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-11-21 11:49:28 +00:00
dependabot-preview[bot]
56ba84a195
Bump pytest from 5.2.4 to 5.3.0 ( #1013 )
...
Bumps [pytest](https://github.com/pytest-dev/pytest ) from 5.2.4 to 5.3.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases )
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest/compare/5.2.4...5.3.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-11-20 14:20:19 +00:00
dependabot-preview[bot]
ed1c0f2e9d
Bump pytest-mock from 1.11.2 to 1.12.0 ( #1014 )
...
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock ) from 1.11.2 to 1.12.0.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases )
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v1.11.2...v1.12.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-11-20 14:19:55 +00:00
dependabot-preview[bot]
022885b86d
Bump twine from 2.0.0 to 3.0.0 ( #1009 )
...
Bumps [twine](https://github.com/pypa/twine ) from 2.0.0 to 3.0.0.
- [Release notes](https://github.com/pypa/twine/releases )
- [Changelog](https://github.com/pypa/twine/blob/master/docs/changelog.rst )
- [Commits](https://github.com/pypa/twine/compare/2.0.0...3.0.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-11-19 18:28:24 +00:00
Niko Strijbol
fd32516e0f
Add exclude_none option ( #1003 )
...
* add `exclude_none` option (#587 )
* run formatter
* Apply @samuelcolvin's suggestions
2019-11-18 13:18:51 +00:00
dependabot-preview[bot]
3b313b2ae7
Bump pytest from 5.2.3 to 5.2.4 ( #1007 )
...
Bumps [pytest](https://github.com/pytest-dev/pytest ) from 5.2.3 to 5.2.4.
- [Release notes](https://github.com/pytest-dev/pytest/releases )
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest/compare/5.2.3...5.2.4 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-11-18 10:14:10 +00:00
dependabot-preview[bot]
7938cb0edf
Bump pytest from 5.2.2 to 5.2.3 ( #999 )
...
Bumps [pytest](https://github.com/pytest-dev/pytest ) from 5.2.2 to 5.2.3.
- [Release notes](https://github.com/pytest-dev/pytest/releases )
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest/compare/5.2.2...5.2.3 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com >
2019-11-15 20:25:51 +00:00
Daniel Smith
c2e0082800
ByteSize conversion ( #996 )
...
* Bytesize implement to conversion
* Changelog
* Lint: changes to single quotes
* Update tests/test_types.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update tests/test_types.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update tests/test_types.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
2019-11-14 16:22:51 +00:00
Koudai Aono
33b3dc1825
mypy plugin support for dataclasses ( #966 )
...
* mypy plugin support for dataclassesv
* fix styles and types
* - change type-hint for `Config`
- change name of an expected file
- update documents
* fix broken a reference of a document.
* - update unittest
- update documents
* fix a document link
* Update docs/mypy_plugin.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update docs/mypy_plugin.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update docs/mypy_plugin.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* remove extra whitespaces on mypy test results
* fix output file name of mypy test
* Update docs/usage/dataclasses.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* use TypeVar for DataclassType
2019-11-14 11:26:46 +00:00
Samuel Colvin
0e8f88611f
build binaries for python 3.8 ( #994 )
...
* build binaries for python 3.8
* change and test with cibuildwheel
* skip codecov on pypi build
* speed up PR ci builds
* better conditional builds
* fix conditional builds
* finish conditional stages
2019-11-14 10:50:34 +00:00
Samuel Colvin
f4cc204138
fix mypy complaint on @root_validator(pre=True) ( #985 )
...
* fix mypy complaint on @root_validator(pre=True)
* fix internal mypy
* use overload on root_validator
2019-11-09 14:45:29 +00:00
Daniel Smith
b92e74d0a6
Bytesize ( #977 )
...
* ByteSize object
* Human readable format
* Lint, tests, and docs
* Update pydantic/errors.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update pydantic/types.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Update pydantic/types.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com >
* Allows human readable decimal descriptor
* Review comments
* Less verbose testing
* ByteSize docs
* Reworks valid units
* Missing type
* tweak tests
2019-11-09 12:39:02 +00:00
Alexander Hirner
c188b3fba8
Feature/dataclass schema defaults ( #980 )
...
* default dataclass field from default_factory
* silence mypy regarding issue 708
* test dataclass factory function default
* test default factory ending up in schema
* add changes md
* add docs for dataclass default factory and basemodel access
* fully print default factory schema
2019-11-09 12:29:15 +00:00
Samuel Colvin
093474ae27
fix coverage on generics.py ( #976 )
2019-11-07 16:24:12 +00:00