From 84a00daebe2d445495bfd282f4ce284004991766 Mon Sep 17 00:00:00 2001 From: siddhant Date: Thu, 1 Oct 2026 13:11:27 +0530 Subject: [PATCH] Fix PydanticUndefinedAnnotation in Folder: keep datetime import at runtime folder.py uses `from __future__ import annotations`, so the `created_at: datetime | None` field annotation is a lazy string that pydantic resolves at runtime when the model is built. The datetime import was under `if TYPE_CHECKING:`, so at runtime the name is undefined and get_folder()/create_folder() raise PydanticUndefinedAnnotation ('Folder is not fully defined; you should define datetime, then call Folder.model_rebuild()'). Move the datetime import to runtime, and set ruff's runtime-evaluated-base-classes to pydantic.BaseModel so flake8-type-checking does not push field-type imports back into a TYPE_CHECKING block (which would reintroduce the bug) for any model. --- pyproject.toml | 5 +++++ rowan/folder.py | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 24d5428..4c15014 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,6 +104,11 @@ ignore = [ [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401", "F403"] +[tool.ruff.lint.flake8-type-checking] +# pydantic evaluates model annotations at runtime, so field-type imports must stay importable at +# runtime (not moved into a TYPE_CHECKING block) or model building raises PydanticUndefinedAnnotation. +runtime-evaluated-base-classes = ["pydantic.BaseModel"] + [tool.ruff.lint.pydocstyle] convention = "google" diff --git a/rowan/folder.py b/rowan/folder.py index a6946b2..3834732 100644 --- a/rowan/folder.py +++ b/rowan/folder.py @@ -1,5 +1,6 @@ from __future__ import annotations +from datetime import datetime from typing import TYPE_CHECKING, Any, Self from pydantic import BaseModel @@ -8,8 +9,6 @@ from .utils import api_client, get_project_uuid if TYPE_CHECKING: - from datetime import datetime - from .workflows.base import Workflow