* ignore Pipfile, .lock files
* add ref_template option
use a string.Template instead of a ref_prefix to allow for more varied`$ref`s to be created.
Template string is expected to have $model_name `identifier `
* formatting / linting
* add changes
* typo
* use string.format instead of string.Template
* remove ref_prefix default
if no `ref_prefix` provided, use the `template_default`
* use ref_template in field_singleton_schema
* fix test_schema_with_ref_template
* add parameters for `test_schema_with_refs`
test name change
test for key error
* provide ref_template default argument
* fix linting
* fix mypy and coverage
* docs and correct model_schema usage
* fastAPI tests actualy caught an error
* linting
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Parse timezone information in time str
* Add description of change fixing issue 1744
* Guard against TZ over 24 hours
* Parse timezone information in time str
* Datetime and time TZ parsed in separate fn
* Sharpen annotation, many return statements
* Fix mypy errors raised on datetime_parse
* fix type hints
* update docs and correct types
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* feat(field): add Enum type support
closes#1735
* test: add extra cases and rename to be more explicit
* refactor: rename enum_validator
* feat: add Enum and IntEnum types support
* docs: add new types
* chore: update change message
* add description of subclass each_item scenario
* add example of subclass validator with each_item
* each_item causes validator to not run when parent class has List field #1566
* Avoid some side effects of default factory
- by calling it only once if possible (fix#1491)
- by not setting the default value in the schema (fix#1520)
* refactor: ensure type is set when using default_factory
* Add (failing) test for Subclass JSON encoding
* Allow subclasses of known types to be encoded with superclass encoder
* Add change file
* Add documentation, fix custom json_encoders and add unit test
Blacken doc
Fix test that worked on my machine
datetime.timestamp() is flakey?
Single quotes only
* Reduce lookups
- Remove last element in `__mro__` as it will always be `object`
- Use .get for compactness
* Regarding the loop
* Move Path and Enum into ENCODERS_BY_TYPE
Sort ENCODERS_BY_TYPE
* improve JSON docs
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* 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>
* 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>
* 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>
* 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>
* fix alias priority so alias_generators don't take priority
* improve test names
* remove debugs
* Apply suggestions from code review
* more tests and allow custom alias_priority on fields
* precedence tests and docs
* tweaks and add change
* suggestions
* allow use of a `.env`-style files in BaseSettings (#607)
* address various issues with initial implementation
- allow specifying `_env_file` kwarg in instantiation
* overrides any `env_file` specified in the `Config` class
- cast `os.environ` as a dict for better consistenty of behavior
- `env_path` should be a `Path` type
- replace `with open()` with `read_text`
- use regex for parsing the dotenv files and throw error on invalid line
- factor out `read_env_file` into separate file for easier testing
* move back into a single file; revert typing changes; use regex better
* pass `_env_file` argument around instead of setting a class attribute
* add dotenv docs
* add dotenv tests
* Add changes file
* Flesh out the docs a bit
* Apply suggestions from @samuelcolvin's code review
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* wrap docs
* add not about priority
* fix tests and imports
* fix tests
* switch to python-dotenv
* cleanup, test example
* more docs tweaks
* typo
* fix tests for dotenv
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* ✨ Add support for generics with __get_validators__
* ✅ Add tests for Generics with __get_validators__
* 📝 Add change note
* ✨ Add support for Generic fields with validation of sub-types
* 📝 Add docs for arbitrary generic types
* ✅ Add tests for generic sub-type validation
* 📝 Update change note. Generic support is not so "basic" now
* 📝 Update docs with code review
* ♻️ Update fields module with code review changes
* ✅ Update tests from code review
* 📝 Update example for generics, try to simplify and explain better
* tweak docs example
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* ✨ Implement support for infinite generators with Iterable
* ✅ Add tests for infinite generators
* 🎨 Fix format
* 📝 Add docs for infinite generators
* 📝 Add changes file
* ✨ Store sub_field with original type parameter to allow custom validation
* 📝 Add example for validating first value in infinite generators
* 🔥 Remove unused import in example
* ✅ Add test for infinite generator with first-value validation
* ♻️ Update fields with code review
* 📝 Update example from code review
* 📝 Update docs and format from code review
* Added optional for root_validator to be skipped if values validation fails
* cleaner usage of skip_on_failure
* skip_on_failure: documentation update