* Better error for unsuported "typing" objects.
Fixes#745
Add a better error message for fields with types from the typing
module that are not directly supported by Pydantic. Previously,
it caused a cryptic assertion failure.
* Add support for frozenset fields.
Also provide an example of their usage.
Fixes#745
* Address review comments.
Fixes#745
* use equals not "is" for int comparison.
* Add advanced exclude support for dict, json and copy
* Add advanced exclude support for dict, json and copy
Add new version section (v0.31)
* Add advanced include support, add more tests, improve code style
Rename ValueExclude to ValueItems and move it to utils
Use old logic to calculate keys, but still exclude it in _iter
* Add more tests for ValueItems
* Removed update arg check in _calculate_keys for return None
This will increase speed when no include or exclude given and skip_defaults is False
* Fix formatting, remove duplicate imports
* Add # pragma: no cover to 'if TYPE_CHECKING:' block
* tweaks and coverage
* fix history
* Add docs
* tweak docs
* support custom root types
* update HISTORY.rst for costom root types
* fix invalid arguments case
* remove the keyword argument of "__root__" in __init__
add a keyword argument of "__root__" in parse_obj
fix documents
create a method for cheking valid field name
* fix parse_obj
* Update docs/index.rst
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Apply suggestions from code review
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* add type cheking for custom root type
* Update docs/index.rst
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update index.rst
* Added alias_provider
* Update HISTORY.rst (+ add alias_provider support #622 by @MrMrRobat)
* Rename alias_provider —> alias_generator
Move docs to config section, reformat example
Separate test_alias_generator
* Update docs/index.rst
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update docs/index.rst
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update docs/index.rst
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Fix conflict between dictionary field config in Config.fields and Config.alias_generator
Add one more condition for applying alias_generator
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Add test for using alias_generator with field schema
* Added generic functionality
* Skip tests in python 3.6
* double quote -> single quote
* Simplified, with more comprehensive tests
* double quote -> single quote
* Remove unintentional file
* Add caching
* don't cythonize generics.py
* Make work with mypy
* Remove __parameters__
* double quote -> single quote i'll remember one day
* More cleanup and validation
* Removed unwanted file
* A little more cleanup, and finish the PR
* Add proper inheritance
* Added note about inheritance to docs
* Added error for double-parameterizing
* Should build for python3.7
* Works with both 3.6 and 3.7
* Fixed bug with caching for single argument
* handle __name__ for generic models
* double quote -> single quote
* Updated error messages
* StrictBool
StrictBool only allows booleans to be parsed. Any other value, no matter
its truthiness, is rejected.
* Fix type of `validate`
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* " => '
* Update the exotic docs with StrictBool
* Fix error message
* Improve docs
* tweak docs.
* added feature post_init_post_parse
* fixed bug where post_init_post_parse was triggered without looking is post_init_original is set
* change double to single quotes
* __doc__ strings fixed back to double quote
* added better way of doing the post_init_post_parse also tests passes now
* removed unused file
* deleted unnecessary test
* update history.rst, changed previouis change 560 to breaking change because it broke the original flow
* update docs, added section post_init_post_parse under dataclasses
* added __post_init_post_parse__ as attribute of DataclassType
* Update HISTORY.rst
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update HISTORY.rst
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update pydantic/dataclasses.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* update docs, added subsection initialize hooks under dataclasses
* my bad
* make tests work again
* removed checking if post_init_parse is none
* correct typo in history
* fixed typo in history.rst
* Color validator MVP
* Color Validator refactored
* Small optimizations applied
* Code coverage improved
* hex processing improved, json encoder and repr added
* Add documentation, update HISTORY (#504)
* Increase test coverage (#504)
* hex helpers refactored (#504)
* Fixes after code review (#509)
* Color Type section in docs reduced
* Check for valid but unnamed colors
* Minor fixes: typo in docs, default value for float comparison function
* rewrite Color
* fix color tests
* tweaks and improve docs
* tweaks and change Color.__str__
* add as_hsla and as_hsl
* support more rgb(a) formats
* add hsl parsing
* parsing hex with alpha channel
* fix hsl parsing
* simpler failure/fallback rules for color display
* storage as floats internally
* tweak docs
* fix type hints
* fix json for Path, FilePath, and DirectoryPath objects, fix#473
* convert to single spaces
* assert result to a string
* Update test_json.py
* encode entire Path hierarchy the same way
* Added validators for dataclass, fix#415
* Added dataclass validators
* Added dataclass validators
* Updated docs for added validating to dataclass
* Updated docs for added validating to dataclass
* Fixed line endings
* Set __validators__ type to Mapping instead of Dict
* Update History
* Use __mro__ instead of __bases__ for gather_validators
* Fix PR number
* Fix issue.rst header underline
* Fix HISTORY.rst merge conflict
* Fix utils.py merge conflict
* fix utils.py
* Rebase and other fixes
* Fix rebase and other issues
* Change history
* Remove unnecessary lines in main.py
* Rebase
* Update history
* Rename ModelType to ModelOrDc
* Added inheritance replace test
* More consiste dataclass validator tests
* fix history.
* Remove Optional ModelOrDc Type
* Fix ModelOrDc
* fix: serialize secrets to json, fix#462
* feat: adjust documentation for secretstr.
* feat: undo unnecessary changes. keep tests.
* fix: tests were broken, now they're fixed again.
* feat: add display fn to SecretStr and SecretBytes, to be used for json output.
* fix: minor typo.
* fix: last few comments.
* feat: add SecretStr and SecretBytes.
* chore: update HISTORY.rst
* fix: file permissions were incorrect.
* feat: lint, format, fix comments.
* feat: changed inner type of SecretBytes in the schema to string as there is no bytes type in json.
* feat: remove format from secret str and secret bytes.
* feat: fix schema mapping.
* IPv{4,6,Any}{Network,Interface} types added, unittests and docs updated
* HISTORY.rst minor update
* Remove strict argument from IP network types
* IP Networks validators and type hints fixed
* tweak history
fix#279
* Support typing.Callable validation.
* Add myself to HISTORY.
* Prove it works with just Callable.
* Document callable validator behavior.
* Support differences in typing module between py36 and py37.
* Remove callable filed from JSON schema with warning.
* Update pydantic/schema.py
Co-Authored-By: proofit404 <proofit404@gmail.com>
* Update tests/test_callable.py
Co-Authored-By: proofit404 <proofit404@gmail.com>
* Update pydantic/validators.py
Co-Authored-By: proofit404 <proofit404@gmail.com>
* Update tests/test_callable.py
Co-Authored-By: proofit404 <proofit404@gmail.com>
* Move callables to the exotic types.
* Move Callable type choice to the import time.
* Move is_callable_type to the utils module.
* Raise warning at skip except.
* Update pydantic/schema.py
Co-Authored-By: proofit404 <proofit404@gmail.com>
* Update docs/index.rst
Co-Authored-By: proofit404 <proofit404@gmail.com>
* Update pydantic/schema.py
Co-Authored-By: proofit404 <proofit404@gmail.com>
* uprev
* Update index.rst (#370)
* Update history.rst
* Make the example a little more concise.
* Use callable import from the utils.
* Remove blank line.
* Remove duplication comments.
* fix history
* support postponed annotations in python 3.7
* support for full ForwardRef
* tweak update_forward_refs
* better ForwardRef resolution
* remove debug, fix linting
* fix comments
* docs and history
* Add support for passing Configs to Dataclasses
* formatting and fixes
* move tests into dataclasses_config.py
* use inherit_config in create_model
fix#276
* Add additional parameters to Schema for validation and annotation (#311)
* Add tests for validation declared via Schema class in defaults
* Add validations to field from declarations in Schema
* Add annotations in generated JSON Schema from validations via Schema
* Augment tests for schema generation
* Simplify validations from Schema in fields, from coverage hints
* Update schema test to use the spec plural "examples"
* Add docs and simple example of the additional parameters for Schema
* Update history
* Fix number of PR in HISTORY
* Refactor check for numeric types, remove break to make coverage happy
* Fix typo in docs, I confused gt with maximum
* Finish docstring for Schema (I had forgotten about it)
* Implement code review requests and lenient_issubclass with tests
* Move Schema to its now file to extract from fields.py but avoid circular imports
* Control coverage
* Schema fixes (#318)
* rearrange code
* cleanup get_annotation_from_schema
* fix typo
* rename _schema to schema
* feat: add support for case insensitive env names
Closes#277
* feedback: just alias os.environ
* doc: update history
* doc: mention case_insensitive option
* refactor: feedback if-else expression assignment
* fix: formatting
* chore: encode black configuration in file to support IDEs
* docs: fix example
* feedback: no suppport for IDEs in this PR
* feedback: style
* Update schema tests to conform to JSON Schema spec
* Add JSON Schema tests for all supported types
including datetime and all supported Pydantic.types
* Add JSON Schema conforming schema sub module
* Update BaseModel to use schema module for JSON Schema generation
and update/simplify internal Schema methods
* Remove Schema code from Field class, replaced with JSON Schema module
* Add submodules to test model name generation for JSON Schemas
* Refactor/rewrite schema module to generate definions and refs
* Update and augment JSON Schema tests to include definitions and refs
and generation of a single JSON Schema with definitions from multiple (unrelated) models
* Add ref_prefix functionality to JSON Schema generation functions
* Test custom ref_prefix in JSON Schema generation
* Remove un-used BaseModel method, now refactored to schema module
* Update formating of test_schema
* Fix long lines in test_schema
* Fix imported but unused in fields
* Fix imported but unused in main.py
* Ignore imported but unused for testing modulec
* Refactor schema module for complexity
* Add conflicting name model to raise coverage
* Add conflicting model to test other flow and raise coverage
* Ignore complexity as destructuring more would make it more complex
and more difficult to understand, similar to .fields.validate
* Fix import sorting
* Update formatting with black, with CI settings
* Fix test for schemas with email validation
* Check if field is class before checking if is subclass
* Improve schema error when using unsuported types
* Add additional tests for corner cases, raise coverage to 100%
* Rename BaseModel.schema_json to schema_str (EAFP Python style)
* Add more tests to utils.display_as_type to increase the coverage for enums
* Remove unused catched error in schema tests
* Fix formatting with black
* Update docs schema example
* Add schema examples for top-level schema with multiple models
* Update docs, section Schema, with new JSON Schema generation details
* Update docs, history, with new features
* Update fields, remove unnecessary schema code for enums
* Update docs, fix links and typos in Schema section
* Trigger CI, as Python 3.7-dev seems to have random CI errors
* Revert Model.schema_str to Model.schema_json as requested
* Remove unnecessary assert in schema module as requested
* Remove annotations in internal functions, as requested
* Refactor get_flat_models_from_fields and reuse
* Use set short assignment syntax in schema module
* Remove unwanted assertion
* Make get_long_model_name a single line f-string
* Update model_name_map, add docstring and remove first return value
* Simplify dict operation in get_model_name_map as requested
* Make more concise model_name_map computation
* Remove bool from field check in schema as is subclass of int
* Make ref_prefix default to None and use global default
* Fix formatting for schema.py
* Refactor field_singleton_schema to use data structures
* Move main functions to top of schema, and add docstrings for them
* Implement __all__, move and order parts of schema
* Remove schema testing sub-package code as requested
* Generate schema testing subpackage in code
* Update schema tests with several related fields to use parametrized pytest
* Fix formatting and imports I missed after rebase
* Fix new formatting errors from CI
* Re-trigger Travis CI, Python 3.7-dev random error again, no re-run click in Travis for non owners
* Trigger annotation error with non-forward references
* Add docstrings for submodel schema
* tweaks and rewrite schema mapping table in python
* support complex defaults
* use str not int as dict keys
* Fix links to JSON Schema and OpenAPI
Using `model.copy(deep=True)` will deep copy a module instance.
Making a deep copy is useful for models that have lists of dicts or
any other non-simple data structure to not accidentally modify data
between instances.
`model.copy()` behaviour is unchanged and will do a shallow copy of
the model instance.
fix#249