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.
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.
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
* 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
* 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
* 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
* 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
* benchmark for attr
* update HISTORY.rst
* * added benchmark using cattr
* add env "ATTRS=1" to benchmark runner to only compare again the two
and save results in separate csv
* added section to docs/index
* nits
* re-run benchmark with cython pydantic; merge results back to main benchmarks results table
* pin pydantic to top of benchmark report
* remove attrs, fix cattrs
* update benchmarks output
* add change
* Add mypy plugin
* Make all arguments optional for BaseSettings
* Get test coverage up
* Add changes
* Add type-checking for BaseModel.construct, and checking for from_orm
* Fix formatting and linting
* Fix the build
* Heavy refactor of plugin and mypy tests
* Make linting pass
* Handle dynamic aliases
* Better organize plugin code
* Add docs
* Add support for error codes
* Fix minor docs typo
* Rename config settings, add docstrings, and incorporate other feedback
* Incorporate feedback
* Update docs, remove dataclasses for cython
* fix mypy example
* release notes for v1
* uprev and tweaks
* Apply suggestions from code review
Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>
* tweak notes, add back link to old docs
* build changelog
* modify behaviour of the construct method
* change construct signature
* Add example for construct function (#907)
* add example for construct
* edit exporting_models
* typo
* add changes file
* code review changes
* fix bad copy paste
* extend example in docs
* use __field_defaults__ in construct
* Rename skip-defaults, and add ability to exclude actual defaults
* Add __defaults__ and deprecation warnings
* Add note about `skip_defaults` to docs
* Incorporate feedback
* Add tests and changes
* Fix reference to .json()
* Merge init_kwargs with env variables recursively to handle nested values
This commit implements `deep_update` function that works as standard
`update` method on dicts, but also recursively updates all the nested
dict values. It allows splitting init arguments between environment
variables and in-code values, as long as they create a valid object
when merged together.
* Add entry to changes directory
* Fix CI/CD checks
* Make deep_copy not mutating, improve tests and type annotations