* Fix#947, fix#1483, fix#1247 allow inner type vars to be present in parent generic classes
- Rename generics._is_type to _is_generic in response to comment:
https://github.com/samuelcolvin/pydantic/pull/1989#discussion_r503400391
- Add more explicit type assertion in generics test
- Add generics tests and unify naming
- Move deep generic tests all into same place in code
- Unify naming convention in deep generic tests using naming of existing tests
- Add tests for multiple inheritance and multiple type vars
- Add generic tests for type hint resolution cases
- Fix edge cases for handling parameters in generic models
- Resolve parameters correctly
- Add tests for special cases like callables
- Add returning generic type directly if parameters and arguments are
identical.
* Apply review comments
- Add docstrings
- Small refactor `generics.__concrete_name__`
- Small refactor of `generics.resolve_type_hints`
- Change `is_identity_typevars_map` to more generic and clearer
`all_identical` and move into utils.
- rename "resolve_type_hint" to "replace_types" so as to not get
confused with "resolve_annotations" from `pydantic.typing`
* Fix generics test coverage
* Update pydantic/generics.py, remove unneeded annotation
mypy understands list comprehensions as they are now
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* Add ability to read secrets from files
* Added docs and updated tests to handle new _build_values argument
* Updated docs to note which types are loaded
* Updated deep_update to take a list of update mappings
* Added warning when fields are not defined as a secret type
* Address additional PR feedback
* improve documentation
* remove redundant UserWarning lines
* allow any field type, not just SecretStr
* regex escape paths in windows 😴
* skip tests on windows 😧🔫
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Add tests for nested literals validator
* Implement flatten literal in validator
* Add test for flatten literal
* Add changelog entry
* Add test skip markers if not Literal
* Refactor: use improved all literals implementation
From Github user PrettyWood, see PR https://github.com/samuelcolvin/pydantic/pull/1364
* Add testing for typing module
Includes moving corresponding tests.
* Remove unnecessary type hint
* Move all literals test to test_utils
* 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
* new URL parsing, fix#603, fix#541
* AnyUrl parts and more tests
* more coverage and db DSNs
* remove DSN methods
* tests for urlstr
* remove debug
* make AnyStr a subtype of str
* fix with cython
* rearranging networking code
* allowing international domains, cleanup
* support international domains
* better URL builder
* allow underscores in subdomains and domains
* tests for json and schema, max length
* urlstr > stricturl
* updating docs
* tweak docs examples
* tweak docs
* 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
* Make schema work for Literal and NewType, fix#646
* Fix test when typing_extensions not installed
* Make literal values fetching 3.6 compatible
* Rework to get around issues with Literal in python 3.6
* Make cython-compatible
* Use union for multiple allowed literal values
* Minor simplification of values-gathering
* Updated history
* 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
* 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
* Get rid of `track` in errors
* Move `display_as_type` func into utils module
* Get rid of error as `namedtuple`
* Renamed `Error.index` to `Error.loc`
* New way to get error type
* New way to get error message
* New errors format
* Renamed `flatten_errors` property to `flat_errors`
* `__slots__` for `Error` and `ValidationError`
* `loc` as `tuple`
* Tests
* Review fixes
* `flatten_errors` as generator