mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-08-05 16:14:08 +00:00
perf: lazy-import in CLI commands to speed up startup (#335)
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
"""Fixture system for seeding databases with dependency resolution."""
|
||||
|
||||
from .enum import LoadStrategy
|
||||
from .registry import Context, FixtureRegistry
|
||||
from .utils import load_fixtures, load_fixtures_by_context
|
||||
from .enum import Context, LoadStrategy
|
||||
|
||||
__all__ = [
|
||||
"Context",
|
||||
@@ -11,3 +9,20 @@ __all__ = [
|
||||
"load_fixtures",
|
||||
"load_fixtures_by_context",
|
||||
]
|
||||
|
||||
_LAZY = {
|
||||
"FixtureRegistry": ".registry",
|
||||
"load_fixtures": ".utils",
|
||||
"load_fixtures_by_context": ".utils",
|
||||
}
|
||||
|
||||
|
||||
def __getattr__(name: str):
|
||||
module_name = _LAZY.get(name)
|
||||
if module_name is None:
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
import importlib
|
||||
|
||||
module = importlib.import_module(module_name, __name__)
|
||||
return getattr(module, name)
|
||||
|
||||
Reference in New Issue
Block a user