* Create utils.py
I needed non pascal case camel case support
* write tests for new `to_lower_camel()` function
* Create 3463-schlerp.md
* added mention to to_lower_camel()
* changed quotes to single tick
* adding second blank line at end of file.
* again, adding second blank line...
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* limit the length of generics._limit_assigned_parameters
* switch to using _limit_cache_size for both
* add change description
* correct `_limit_cache_size` cache
* implemented LimitedDict
* try using UserDict
* try upgrading cython
* stop LimitedDict from inheriting from dict
* separate LimitedDict for typing checking :-(
* fix for __class_getitem__
* refactor: extra `BaseConfig` and `Extra` in dedicated `config` module
* refactor: clean useless `#noqa: F401`
* refactor: clean useless `#noqa: F811`
* refactor: replace enum check
Error with 3.10
> DeprecationWarning: accessing one member from another is not supported
* refactor: avoid using `distutils` directly
error with python 3.10
> DeprecationWarning: The distutils package is deprecated and slated
> for removal in Python 3.12.
> Use setuptools or check PEP 632 for potential alternatives
* fix: `__annotations__` always exists
* fix: origin of `typing.Hashable` is not `None`
* ci: add run with 3.10.0b2
* docs: add 3.10
* feat: support `|` union operator properly
`|` operator has origin `types.Union` (and not `typing.Union`)
* fix: enum repr is different with 3.10+
* fix: error message changed a bit
change from basic `__init__` to `test_hashable_required.<locals>.MyDataclass.__init__()` (with `__qualname__`)
* fix: always exists and is not inherited anymore
* fix: avoid calling `asyncio.get_event_loop` directly
With python 3.10, calling it results in
> DeprecationWarning: There is no current event loop
* fix(ci): do not run 3.10 on linux for now
For now it can not be compiled.
Let's just skip the check on linux for now instead of tuning the CI pipeline
* fix(ci): ignore DeprecationWarning raised by `mypy` on windows
* docs: add change file
* fix: generate a valid name in schema for `Enum` classes
* test: add schema with generic enum
* (erase me): just to check fastapi tests
* Revert "(erase me): just to check fastapi tests"
This reverts commit f334c4b575d413639d26c17c2c36d30333afcf7c.
* fix linting 😴
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Add exclude/include as field parameters
- Add "exclude" / "include" as a field parameter so that it can be
configured using model config (or fields) instead of purely at
`.dict` / `.json` export time.
- Unify merging logic of advanced include/exclude fields
- Add tests for merging logic and field/config exclude/include params
- Closes#660
* Precompute include/exclude fields for class
* Increase test coverage
* Remove (now) redundant type checks in Model._iter: New
exclusion/inclusion algorithms guarantee that no sets are passed further down.
* Add docs for advanced field level exclude/include settings
* Minimal optimization for simple exclude/include export
Running benchmarks this vs. master is at:
this: pydantic best=33.225μs/iter avg=33.940μs/iter stdev=1.120μs/iter version=1.7.3
master: pydantic best=32.901μs/iter avg=33.276μs/iter stdev=0.242μs/iter version=1.7.3
* Apply review comments on exclude/enclude field arguments
* Fix/simplify type annotations
* Allow both ``True`` and ``Ellipsis`` to be used to indicate full field
exclusion
* Reenable hypothesis plugin (removed by mistake)
* Update advanced include/include docs to use ``True`` instead of ``...``
* Move field info exclude/include updates into FieldInfo class
This way, the model field object does not need to concern itself with
dealing with field into specific fields.
(Same was done for alias in a previous commit).
* remove double back tick in markdown.
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* remove DeprecationWarnings from v1 release
* coverage on unpickling Undefined private attributes
* coverage on undefined in copy, allow Undefined to be pickled unchanged
* fix coverage of model._iter()
* Infer root type from Annotated
* Extract Field from Annotated
* Add changelog
* Extend existing get_args/get_origin
* Fix Annotated on py3.6 without typing-extensions
* Handle Ellipsis default
* Fix field reuse after FieldInfo.default mutation
* Fix ci
* 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