I'm not sure to understand how the Pydantic validation works. I know each attribute is validated based on the type. However I found it strange that method decorator are validated.
from pydantic import BaseModel
from functools import cache
class Foo(BaseModel):
a : int
@cache
def bar(self) :
return None
run pytest
raise : E RuntimeError: no validator found for <class 'functools._lru_cache_wrapper'>, see `arbitrary_types_allowed` in Config
This workaround works however I'm not sure of what I'm doing so I'll be glad to have an explanation of why pydantic validate the method's property.
This behaviour append on Pydantic 1, Not anymore on Pydantic 2