Переглянути джерело

fix: properly initialize inputs in Composite, validation for permitted None

Sam Jaffe 1 місяць тому
батько
коміт
b65b2ab730
2 змінених файлів з 7 додано та 6 видалено
  1. 1 0
      src/cipy/action.py
  2. 6 6
      src/cipy/common.py

+ 1 - 0
src/cipy/action.py

@@ -149,6 +149,7 @@ class Composite(Action):
 
         with context.extend(steps=self._results) as outctx:
             for step in self.steps:
+                context.fabricate(step, "inputs")
                 self._counter += 1
 
                 if step.enabled(status, context):

+ 6 - 6
src/cipy/common.py

@@ -194,13 +194,13 @@ def _validate(model: BaseModel):
     """Perform the actual model validation that we sabotaged w/ required() and similar functions"""
     for k, fld in model.__pydantic_fields__.items():
         attr = getattr(model, k)
-        if fld.annotation is None:
+        if fld.annotation is None or isinstance(attr, fld.annotation):
             continue
 
         if isinstance(attr, (Ref, Factory, NoneType)):
             raise TypeError(f"fld '{k}' in {type(model).__qualname__} is unset")
-        if not isinstance(attr, fld.annotation):
-            raise TypeError(
-                f"field '{k}' in {type(model).__qualname__} is of the wrong type "
-                f"(should be {fld.annotation})"
-            )
+
+        raise TypeError(
+            f"field '{k}' in {type(model).__qualname__} is of the wrong type "
+            f"(should be {fld.annotation})"
+        )