Skip to content

AnyUrl & HttpUrl validation error #571

Closed
@rglKali

Description

@rglKali

OS: Ubuntu 22.04.3 LTS (WSL2)

Python: 3.11.6

Redis: 7.2.2

Code sample:

from pydantic import HttpUrl, BaseModel
from redis_om import JsonModel


class Crush(BaseModel):
    http: HttpUrl

class Test(JsonModel):
    http: HttpUrl

Shell test:

kali@rglKali:~/$ python
Python 3.11.6 (main, Oct 17 2023, 16:29:19) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import Crush, Test
>>> Crush(http='https://avatars.githubusercontent.com/u/1529926?s=48&v=4')
Crush(http=Url('https://avatars.githubusercontent.com/u/1529926?s=48&v=4'))
>>> Test(http='https://avatars.githubusercontent.com/u/1529926?s=48&v=4')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kali/venv/lib/python3.11/site-packages/redis_om/model/model.py", line 1683, in __init__
    super().__init__(*args, **kwargs)
  File "/home/kali/venv/lib/python3.11/site-packages/redis_om/model/model.py", line 1295, in __init__
    super().__init__(**data)
  File "/home/kali/venv/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for Test
http
  instance of Url expected (type=type_error.arbitrary_type; expected_arbitrary_type=Url)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions