* Remove Cython
* fix CI
* fix coverage
* fix tests
* switching to pypyroject.toml
* pre-commit all and use pre-commit for linting
* no mypy tests on macos and windows on ci, use flake8-pyproject
* fix docs and tests CI
* check build is working
* drop pytest-cov
* window and macos ci with 3.11, reduce filtering
* use pip-tools to pin all dependencies
* fix docs and fastapi tests
* fix test deps for 3.7
* no cache on tests job
* revert fastapi changes, fix coverage
* fix mypy coverage
* test with older mypy
* dotenv not required for mypy tests
* split testing requirements std and extra
* typo
* @PrettyWood comments
* correct branch name
* mypy python_version and pr template
* Generate docs exampels for Python 3.10 and above
Code quality is not great and main intent here is to show the result.
* Fix docs build on 3.9
* Build docs on 3.10
* What's Python 3.1?
* Create temp dir if not exists
* Refactor and improve imlementetion
* Keep runtime typing in examples
* Revert unrelated formatting changes
* Add changes file
* Allow specifying requirements in examples
* Pin autoflake and pyupgrade
* Add docs/build to Makefile lint/format/mypy
* ignore_missing_imports for ansi2html and devtools
* Add .tmp-projections to .gitignore
* Remove dont-upgrade now when Pattern is supported
* Update postponed evaluation examples
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Add GetterDict example
* Update docs/usage/models.md
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Fix(docs): remove colon to separate unrelated clauses
The colon at the end of the line "The fields which were supplied when user was initialised:" suggests that the code following it is related.
Changed it to a period.
* Include change summary readme.
* Propagate`ClassVar`s to sub-models
Currently, if a `ClassVar` is defined on a model and re-defined
on a sub-model omitting the `ClassVar` annotation, Pydantic produces an
unrelated error:
NameError: Field name "..." shadows a BaseModel attribute ...
This check was introduced to prevent shadowing Pydantic's own methods
and attributes defined on the `BaseModel` class. Following this change,
class variables (that is, variables annotated with `ClassVar`)
defined on parent models will be inherited by sub-models and
will be overwritable without having to reapply the annotation.
Closes#2061.
* docs: explain how attributes are excluded and when to use `PrivateAttr`
* feat: add support for `NamedTuple` and `TypedDict` types
* support `total=False`
* tests: fix ci with python < 3.8 without typing-extensions
* chore: improve mypy
* chore: @samuelcolvin remarks
* refactor: move tests in dedicated file
* docs: add annotated types section with examples
* feat: support properly required and optional fields
* chore(deps-dev): bump typing_extensions
* docs: add a note for `typing_extensions`
* chore: update message to be more accurate
* feat: pass down config to created models
* feat: add util methods to create model from TypedDict or NamedTuple
* refactor: rename into typeddict and namedtuple
* test: add utils tests
* chore: fix lint
* chore: improve test
* refactor: rename utils to match the rest
* chore: update change
* docs: add section for create_model_from_{namedtuple,typeddict}
* refactor: rename typed_dict/named_tuple
* feat: support schema with TypedDict
* feat: support schema for NamedTuple
* feat: add json support for NamedTuple
* chore: rewording
* refactor: use parse_obj
* fix: add check for max items in tuple
* docs: separate typing.NamedTuple and collections.namedtuple
* Add private attributes support
* Add more blank lines in example
* Add changes file
* Update docs/usage/models.md
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* fix after bad merge
* Add PrivateAttr, Config.underscore_attrs_are_private
* remove unrelated change in utils.py
* add # noqa: C901 (ignore complexity) to __setattr__
(see comment in PR)
* add annotation to Config.underscore_attrs_are_private
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* use sunder names
* mention underscore_attrs_are_private in model_config.md
* add comment about default factory
* fix comment
* fix comment
* clarify that both dunder and sunder names might be used
* tweak docs and name
* _set_default_private_attributes -> _init_private_attributes
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* use new name _init_private_attributes
* move tests
* copy private attributes in BaseModel.copy()
* add test for default and default_factory used together
* fix linting
* more tests, default_factory kw only
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Allow generics to extend concrete classes. fixes#2005
* Update the docs
* Updote the changes
* Convert double quotes to single quotes
* Fix formatting
* Add a check for data
* Update example
* Add a skip_36 decorator that got accidentally deleted when resolving conflicts.
* 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 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>
* Implement Optional required, when creating a ModelField(required=True), make it persist
* Add test for nullable required
* Improve formatting of Undefined custom object
* Refactor field infer/creation with Undefined to make it idempotent
Needed for when _type_analysis is re-run in Generics
* Add PR changes
* Increment/update tests with code review
* Update/refactor Undefined implementation with code review
* Fix BoolUndefined as string type for mypy, not runtime
* Add docs about required Optional
* Add explicit tests for Any
* Apply code review requested changes
* move tests out of test_validators.py
* 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
* release notes for v1
* uprev and tweaks
* Apply suggestions from code review
Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>
* tweak notes, add back link to old docs
* build changelog
* modify behaviour of the construct method
* change construct signature
* Add example for construct function (#907)
* add example for construct
* edit exporting_models
* typo
* add changes file
* code review changes
* fix bad copy paste
* extend example in docs
* use __field_defaults__ in construct
* starting insert prints
* working exec_script
* remove prints, fix exec_examples.py
* more cleanup of examples, better model printing
* upgrade netlify runtime
* extra docs deps
* few more small tweaks