* add tests that should pass
But we have those errors
226: error: Item "str" of "Union[UUID, str]" has no attribute "hex" [union-attr]
227: error: Item "str" of "Union[UUID, str]" has no attribute "hex" [union-attr]
228: error: Item "str" of "Union[Path, str]" has no attribute "absolute" [union-attr]
229: error: Item "str" of "Union[Path, str]" has no attribute "absolute" [union-attr]
230: error: Item "str" of "Union[Path, str]" has no attribute "absolute" [union-attr]
231: error: Item "str" of "Union[Path, str]" has no attribute "absolute" [union-attr]
* fix: right types should be valid
* remove new useless `type: ignore`
* docs: add change file
* fix(mypy): handle FilePath and DirectoryPath custom types
closes#2098
* fix(mypy): handle almost all other custom types
* remove mypy overwrite when extra logic is set
* fix unused mypy ignore
* 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
* Add __init__ for ForwardRef stub
* Add changes file
* Update changes/1738-sirtelemak.md
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Add mypy check for ForwardRef
* Add Black line after if statement
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Sergey Teplyakov <s.teplyakov@fitingo.com>
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
* 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
* 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