* Add static checking for default and default_factory
* Describe PR change
* Remove unnecessary booleans default_specified and default_factory_specified
* Add test with default without Field
* Apply suggestions from code review
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Fix tests
* Add handling of Overload types for mypy0.971
* Avoid to use walrus operator
* Support mypy 0.910 for overloaded types
* Increase coverage for mypy plugin
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* feature: add a `frozen` parameter to config
For now, `frozen` is a strict duplication of `allow_mutation` parameter
i.e. setting `frozen=True` does everything that `allow_mutation=False` does.
NB: this does not change the behavior of `allow_mutation`.
In next commit, setting `frozen=True` will also make the BaseModel hashable
while the existing behavior of `allow_mutation` will not be updated.
* refactor: factorise immutability tests
* feature: generate a hash function when frozen is True
Now, setting `frozen=True` also generate a hash function for the model
i.e. `__hash__` is not `None`. This makes instances of the model potentially
hashable if all the attributes are hashable. (default: `False`)
* reviewer feedback: use hash of the class instead of the super
* reviewer feedback: fix spelling checks
* reviewer feedback: update changes description
* test: remwork mypy tests in order to catch only frozen related errors
Before: there were errors about other stuff than frozen behavior
After: The modification catch only errot related to the frozen behavior
* test: split test_immutablity in 2 functions
One function tests the behavior: 'the model is mutable'
The other tests the behavior:OC 'the model is immutable'
* test mutability: remove the unnecessary parametrization
* test immutability: remove assertion that do not test frozen behavior
* mypy plugin support for dataclassesv
* fix styles and types
* - change type-hint for `Config`
- change name of an expected file
- update documents
* fix broken a reference of a document.
* - update unittest
- update documents
* fix a document link
* Update docs/mypy_plugin.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update docs/mypy_plugin.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* Update docs/mypy_plugin.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* remove extra whitespaces on mypy test results
* fix output file name of mypy test
* Update docs/usage/dataclasses.md
Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
* use TypeVar for DataclassType
* Add mypy plugin
* Make all arguments optional for BaseSettings
* Get test coverage up
* Add changes
* Add type-checking for BaseModel.construct, and checking for from_orm
* Fix formatting and linting
* Fix the build
* Heavy refactor of plugin and mypy tests
* Make linting pass
* Handle dynamic aliases
* Better organize plugin code
* Add docs
* Add support for error codes
* Fix minor docs typo
* Rename config settings, add docstrings, and incorporate other feedback
* Incorporate feedback
* Update docs, remove dataclasses for cython
* fix mypy example