-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
If an error occurs in the cached_property input_file_model of the Code base model the error is not raised and the instantiated model will not have an input_file_model property. Which eventually does raise an error when input_file_model is used.
Attempts to do a very simple reproduction this do not yield the same behavior so far. I'm not sure what the underlying cause for this is.
Example:
from pydantic import BaseModel
from functools import cached_property
class Sim(BaseModel):
sim_name: str
@property
def foo(self):
print(not_a_variable)
print(self.sim_name * 5)
class Model(BaseModel):
sim: Sim
def model_post_init(self, __context) -> None:
x = self.sim.foo
Model(sim={'sim_name': 'bob'})
Raises as expected:
NameError: name 'not_a_variable' is not defined
and not (as seen in Configuration right now):
"AttributeError: 'Sim' object has no attribute 'foo'"
Metadata
Metadata
Assignees
Labels
No labels