outer_type_ -> annotation

This commit is contained in:
Benedikt Bartscher 2024-02-28 23:55:35 +01:00
parent 95f9b12829
commit 8b2d0b40bc
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View File

@ -286,7 +286,7 @@ class Component(BaseComponent, ABC):
if kwargs[key] is None:
raise TypeError
expected_type = fields[key].outer_type_.__args__[0]
expected_type = fields[key].annotation.__args__[0]
# validate literal fields.
types.validate_literal(
key, value, expected_type, type(self).__name__
@ -301,7 +301,7 @@ class Component(BaseComponent, ABC):
except TypeError:
# If it is not a valid var, check the base types.
passed_type = type(value)
expected_type = fields[key].outer_type_
expected_type = fields[key].annotation
if not types._issubclass(passed_type, expected_type):
value_name = value._var_name if isinstance(value, Var) else value
raise TypeError(
@ -581,7 +581,7 @@ class Component(BaseComponent, ABC):
name
for name, field in cls.get_fields().items()
if name in cls.get_props()
and types._issubclass(field.outer_type_, Component)
and types._issubclass(field.annotation, Component)
}
@classmethod

View File

@ -432,7 +432,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
# Set the base and computed vars.
cls.base_vars = {
f.name: BaseVar(_var_name=f.name, _var_type=f.outer_type_)._var_set_state(
f.name: BaseVar(_var_name=f.name, _var_type=f.annotation)._var_set_state(
cls
)
for f in cls.get_fields().values()