Skip to content

Commit 5e74692

Browse files
committed
feat: centralized model rebuilding for more maintainable Pydantic circular dependencies
Implements a centralized model rebuilding strategy for Pydantic model rebuilding. Instead of maintaing these model rebuilds in each file, we now can import circular dependencies in an `if TYPE_CHECKING:` block. The model rebuild module will then automatically handle model rebuilds, walking the view_model module and dynamically rebuilding our models based on their sub-classes. This should substantially increase ease of maintainability when adding dependent Pydantic models.
1 parent 4962f4f commit 5e74692

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/mavedb/server_main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
UserAgentPlugin,
1919
)
2020

21+
# Import the model rebuild module to ensure all view model forward references are resolved
22+
import mavedb.view_models.model_rebuild # noqa: F401
2123
from mavedb import __version__
2224
from mavedb.lib.exceptions import (
2325
AmbiguousIdentifierError,

0 commit comments

Comments
 (0)