* ✨ Add autocomplete support for VS Code, via dataclass_transform
* 📝 Update changes
* 📝 Add docs for VS Code
* 📝 Clarify strict type error checks alternatives, include example with cast()
* ♻️ Update BaseSettings annotation to improve editor support
keeping editor support for BaseSetting's custom Config, but preventing __config__ from showing in constructor on editors supporting dataclass_transform
* 🎨 Remove unused type: ignore comment
* 🎨 Update type annotations for BaseSettings and BaseModel to use ClassVar where suitable
to improve editor support with type annotations and dataclass_transform
* 🎨 Apply ClassVars again
* 📝 Simplify VS Code docs terms
refer mainly to Pylance and clarify the relationship with Pyright
* 📝 Add link to Pylance FAQ
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Fix bug when mypy plugin fail on construct method call
* Update type annotation for __config__ field
* Remove type ignore
* Update changes/2753-uriyyo.md
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Thanks to @PrettyWood for pointing me to the right place to fix this!
Since I was told that both NamedTuple and TypedDict use the same
__pydantic_model__ machinery that dataclasses do, I checked and found
that TypedDict had the same bug, and fixed that too.
Tests for both issues are included, which fail without the associated
fixes being applied.
* Added dark color scheme for docs
Added alternative, dark color scheme for docs, which should be automatically activated if user's browser presents the `prefers-color-scheme: dark` media query.
* switch icons
* add change file
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Parse JSON for union type with complex subfields (#2936)
* style
* simplify
Co-authored-by: Christopher Bartz <c.bartz@zbw.eu>
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Add test for type hint subclass as default
* Fix support for using a subclass of an annotation as a default
* Add changes file
* add check in test
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Add a TypedDict class for error objects
This adds more specific typing for the dictionaries in
`ValidationError.errors()`. This shouldn't introduce any functional
change.
* quotes
* split required and not required keys
* type but be a class
* workaround cython (can't wait for v3)
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Fix: _pydantic_post_init() reassigns __dict__ and removes properties added to the object, for example in __new__(), breaking integration with SQLAlchemy and other libraries #3043
* Added changes file
* Fix 2860
When dealing with JsonWrapper, replace the inner type when constructing
a a generic model.
* tweak and schema test
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Renamed schema variable name to schema_ as there is a schema function already defined
* Same approach in enum_process_schema()
* added changes file
* Update changes/2724-shahriyarr.md
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* last shadow rename
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* add `FileUrl` type for `file://` schemes
Also add a `host_required` parameter, True by default,
False in `FileUrl` and `RedisDsn`.
* chore: useless extra in assert statement
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* added KafkaDsn to network
* added short description to chandes folder
* added default non-displayable ports to HttpUrl model
* added info to changes folder
* fix: support non default ports in HttpUrl
* fix pr issues
* remove noqa
* add more typing by @PrettyWood
* add default http and https ports to `HttpUrl` model
* fix mypy
* chore: do not add implementation details
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Added suport to postgresql async driver
* Added postgres+asyncpg in the doc.
* Added changes file
* Added postgresql+pg8000 schema
* ran make format
* Update docs/usage/types.md
Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
* Changed from schema to scheme
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* fixed typo scheme
* fixed merge schema
* changed to one line description
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* added others DBAPI dialects.
* Added two # by PrettyWood
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* fix typo by PrettyWood
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* Fixed typo by PrettyWood
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* added postgresql+psycopg2 in changes dir
* Fixed typo by @samuelcolvin
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* docs: fix typo
* chore: sort alphabetically
Co-authored-by: Fernando Ike <fernando.ike@maburix.com>
Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Allow collections.abc.Callable to be used as type in python 3.9
* Add is_none_type as function to check none types by identity
* Modify `typing.is_none_type` to work in python 3.6 and 3.7
* Add tests for none types in typing.py
* Apply review comments on #2519
* Add different implementations depending on python version
* Add tests for is_none_type
* Add change entry
* Fix field info repr
* Remove unneeded try/except for python < 3.8
* Add comment explaining alternative is_none_type implementation
* fix: typo
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* refactor: extra `BaseConfig` and `Extra` in dedicated `config` module
* refactor: clean useless `#noqa: F401`
* refactor: clean useless `#noqa: F811`
* refactor: replace enum check
Error with 3.10
> DeprecationWarning: accessing one member from another is not supported
* refactor: avoid using `distutils` directly
error with python 3.10
> DeprecationWarning: The distutils package is deprecated and slated
> for removal in Python 3.12.
> Use setuptools or check PEP 632 for potential alternatives
* fix: `__annotations__` always exists
* fix: origin of `typing.Hashable` is not `None`
* ci: add run with 3.10.0b2
* docs: add 3.10
* feat: support `|` union operator properly
`|` operator has origin `types.Union` (and not `typing.Union`)
* fix: enum repr is different with 3.10+
* fix: error message changed a bit
change from basic `__init__` to `test_hashable_required.<locals>.MyDataclass.__init__()` (with `__qualname__`)
* fix: always exists and is not inherited anymore
* fix: avoid calling `asyncio.get_event_loop` directly
With python 3.10, calling it results in
> DeprecationWarning: There is no current event loop
* fix(ci): do not run 3.10 on linux for now
For now it can not be compiled.
Let's just skip the check on linux for now instead of tuning the CI pipeline
* fix(ci): ignore DeprecationWarning raised by `mypy` on windows
* docs: add change file
* Add GetterDict example
* Update docs/usage/models.md
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* add repr parameter to hide a field from repr()
* fix styling issues
… found by flake8.
* fix type annotation issues
* correctly name changes file
* test hiding default values from repr() of a Field
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* fix: generate a valid name in schema for `Enum` classes
* test: add schema with generic enum
* (erase me): just to check fastapi tests
* Revert "(erase me): just to check fastapi tests"
This reverts commit f334c4b575d413639d26c17c2c36d30333afcf7c.
* fix linting 😴
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* fix: provide __version__ attribute
Pyinstaller is giving an error packaging a script that uses pydantic, "AttributeError: Module 'pydantic' has no attribute '__version__'"
See Issue #2572
* chore: add md file in changes folder
* test: __version__ attribute of pydantic module