Skip to content

Commit b2f268c

Browse files
committed
Refactor: Move validation imports to top-level and ensure app_namespace and full_flow_name validation
1 parent e4ecb40 commit b2f268c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

python/cocoindex/flow.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
import inspect
1111
import re
1212

13-
from .validation import validate_flow_name, NamingError
13+
from .validation import (
14+
validate_flow_name,
15+
NamingError,
16+
validate_full_flow_name,
17+
validate_target_name,
18+
)
1419

1520
from dataclasses import dataclass
1621
from enum import Enum
@@ -386,9 +391,6 @@ def export(
386391
387392
`vector_index` is for backward compatibility only. Please use `vector_indexes` instead.
388393
"""
389-
from .validation import (
390-
validate_target_name,
391-
) # Import locally to avoid circular imports
392394

393395
validate_target_name(target_name)
394396
if not isinstance(target_spec, op.TargetSpec):
@@ -670,6 +672,7 @@ class Flow:
670672
def __init__(
671673
self, name: str, full_name: str, engine_flow_creator: Callable[[], _engine.Flow]
672674
):
675+
validate_full_flow_name(full_name)
673676
self._name = name
674677
self._full_name = full_name
675678
engine_flow = None

python/cocoindex/setting.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from typing import Callable, Self, Any, overload
88
from dataclasses import dataclass
9+
from .validation import validate_app_namespace_name
910

1011
_app_namespace: str = ""
1112

@@ -27,6 +28,8 @@ def split_app_namespace(full_name: str, delimiter: str) -> tuple[str, str]:
2728

2829
def set_app_namespace(app_namespace: str) -> None:
2930
"""Set the application namespace."""
31+
if app_namespace:
32+
validate_app_namespace_name(app_namespace)
3033
global _app_namespace # pylint: disable=global-statement
3134
_app_namespace = app_namespace
3235

0 commit comments

Comments
 (0)