* correct naem of validate_arguments in docs
* bump
* Update docs/usage/validation_decorator.md
Co-Authored-By: Stephen Brown II <Stephen.Brown2@gmail.com>
* Apply suggestions from code review
Co-Authored-By: Stephen Brown II <Stephen.Brown2@gmail.com>
Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
* make secret types idempotent
* remove idempotent from secret types example.
add note to docs for idempotently creating secret types.
use isinstance for comparing when creating secret types idempotently.
add assert for idempotent secret types test.
* tweaks
Co-authored-by: Lasse Gravesen <lasse.gravesen@falcon.io>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* ignore pyenv generated file
* Allow `None` as input to all optional list fields
* skip test on python 3.6
* fix mypy error, line length
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Have BaseModel inherit from Representation
This changes the inheritance so that `BaseModel` *actually* inherits from `Representation`, rather than just having the same methods as it. While this doesn't actually affect the runtime, it does make mypy happier.
Fixes https://github.com/samuelcolvin/pydantic/issues/1310
* Add '__dict__' back into slots
* Add JSON Benchmark
* Apply iterator suggestions from code review
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Reorganize run to avoid parsing time in json test
* tweak json benchmarks
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Add change file
* Add datetime field to default_factory example
Print instead of assert
Remove bad quotes
Remove bad quotes from all examples
* fix change description
* remove 'avoid-escape' from setup.cfg
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Raise informative TypeError when passing bad exclude kwargs to export
* Cleanup spurious example
* Add __all__ keyword to enable excluding fields from all members of a list/tuple of child submodels
* Add changelog
* Fix MD format inconsistencies and consolidate export tests
* Excluding from exported List of Dict fields with "__all__"
* tweaks
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* use foo.__class__ instead of type(foo) as 5% faster
* Fix tests for default_factory
* Fix mypy unused ignores
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Fix typo breaking pydantic-only benchmarks when TestCAttrs not available
* Add Pydantic-only benchmarks to CI
Remove requirements for pydantic-only benchmarks and update python ver
* Benchmarks output tweaks
- Left pad by only 4 more than the longest benchmark
- Add run number/total to each run
- Summarize what is being tested at beginning
* update_forward_refs now modifies only a copy of __dict__ of cls.__module__
* changes
* test for update_forward_refs
* fixed brackets
* black changes fixed
* make format
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Change str_validator() return type to str
* Make pattern_validator() accept pre-compiled Pattern objects.
Resolves#1237.
* fix str_validator return type
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* README change to make type annotations valid
* example fixed to have valid type annotations
* changes description
* Update README.md
explicit assignment for an optional field
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update docs/examples/index_main.py
explicit assignment for an optional field
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Add right __init__ signature generation
* Add params overlay support for custom __init__, enhance tests
* Change fake_ini creation to solve AttributeError in cython
AttributeError: attribute '__code__' of 'cython_function_or_method' objects is not writable
Possible there's other attrs that cannot be set in cython, but can't check myself yet
* Cython compatibility, add __signature__, ignore non-identifiers fields
Moved tests to separate file
Moved __init__ creation to utils
* Remove # pragma: no cover
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Fixed adding signature to doc, some compatibility fixes
* Changed None to tuple() for py3.8 compatibility
* Finally (hope so) fix issues with closure. Add new docstring each time
* coverage for UndefinedType
* Checking signature more simple and obvious way
* Changed doc caption to simple message, used Undefined, merge conflicts
* Compatibility with py3.6
* Add changes/ file
* Ah, that space... Reformatted and ready to go!
* Update pydantic/main.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update pydantic/main.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Fix signature for properties declared as fields
* Sort imports
* Add comments
* Generate BaseModel signature instead of __init__ signature
* Fixed imports
* Minor improvements from review
* Add docs for model signature
* Delete unused imports
* Fix formatting in tests
* Remove inspect imports from top level
* Update docs/examples/models_signature.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Add missing import
* Remove notes from doc
* change hypothesis-auto mention to hypothesis
* Use None as slice end instead of len()
* tweak generate_model_signature
* improve docs
* Revert af3dd4d, add fields to custom init only if var_kw declared
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Refactor ._iter() method:
Moved all keys-related stuff (include, exclude, etc.) to ._iter()
Removed redundant iteration through default values
Almost all arguments checks moved out of loops, so checks happen once
Fast yield from .__dict__ on plain .iter() (x10 boost)
Removed redundant set(dict.keys()) in ._calculate_keys()
* Moved back from nested generator checks to checks, optimized copy a bit
* 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>
* __str__ and __repr__ inheritance for models, fix#1022 (#1023)
* add testimonials section to docs with reference to python bytes podcast episode (#1025)
* add testimonials section with reference to python bytes podcast episode
* added description to changes directory
* 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>
* 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
* 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
* 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
* 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
* Add changes file
* Delete unrelated files
* Add check that k in fields before using alias
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Remove redundant call to __iter__
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Use typing.AbstractSet
* Update pydantic/main.py
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Colin Sullivan <csullivan@brandwatch.com>
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
* feat: add pydantic.color.Color as available type for Pydantic color fields
* chore: test for color
* chore: change md
* fix: assertion is incorrect
* fix: logic on _original assignment
* fix: value is set to value._original in the isinstance conditional
fix: remove ._original conditional (logic is set earlier in the method)
fix: removed pydantic.color.Color line from errorstring
* chore: revert error message adjust
* chore: grammaer ;)
* starting validation_decorator
* correct skip_pre_38
* fix coverage and type hints
* mypy tests and move to class based decorator
* 3.6 fix, prevent duplicate github actions
* correct py 3.6 check
* better errors
* cleaner field names for args and kwargs
* add change and comments
* starting docs
* back to 3.7 for docs
* docs
* bump
* add async example and fix print indents
* allow type annotations as strings
* python 3.8 in docs
* Be more specific about the meaning of Config.extra
When reading through the docs as a beginner, it was not clear to me what the difference between `'allow'` and `'ignore'` was. I fixed this by adding a short description of each of the options from what I can tell from reading the source code.
Is there a better way to format this? Maybe as a list?
(ps, thanks for the cool library)
* tiny further clarification
* sorry...
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>