Please confirm the following
Describe the bug
In https://yarl.aio-libs.org/en/latest/#why-isn-t-boolean-supported-by-the-url-query-api it is stated that:
The URL could be used as a field type in pydantic models seamlessly:
from pydantic import BaseModel
from yarl import URL
class Model(BaseModel):
url: URL
However, the example does not work out of the box:
PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'yarl.URL'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.
For further information visit https://errors.pydantic.dev/2.12/u/schema-for-unknown-type
The working example would be:
In [20]: class C(pydantic.BaseModel):
...: model_config = pydantic.ConfigDict(arbitrary_types_allowed=True)
...: endpoint: yarl.URL
Versions tested:
In [23]: pydantic.__version__
Out[23]: '2.12.5'
In [24]: yarl.__version__
Out[24]: '1.22.0'
In [26]: sys.version
Out[26]: '3.10.11 (v3.10.11:7d4cc5aa85, Apr 4 2023, 19:05:19) [Clang 13.0.0 (clang-1300.0.29.30)]'
To Reproduce
...
Expected behavior
...
Logs/tracebacks
Python Version
In [26]: sys.version
Out[26]: '3.10.11 (v3.10.11:7d4cc5aa85, Apr 4 2023, 19:05:19) [Clang 13.0.0 (clang-1300.0.29.30)]'
multidict Version
In [28]: multidict.__version__
Out[28]: '6.7.1'
propcache Version
In [31]: propcache.__version__
Out[31]: '0.4.1'
yarl Version
In [24]: yarl.__version__
Out[24]: '1.22.0'
OS
macOS
Additional context
Pls consider simplifying the bug report form 🙏🏻
Please confirm the following
vulnerability, to the best of my knowledge. (These must be shared by
submitting this report form instead, if
any hesitation exists.)
Describe the bug
In https://yarl.aio-libs.org/en/latest/#why-isn-t-boolean-supported-by-the-url-query-api it is stated that:
However, the example does not work out of the box:
The working example would be:
Versions tested:
To Reproduce
...
Expected behavior
...
Logs/tracebacks
Python Version
multidict Version
propcache Version
yarl Version
OS
macOS
Additional context
Pls consider simplifying the bug report form 🙏🏻