From 09a6bff256192cf9466e92dc1597d9060581a13e Mon Sep 17 00:00:00 2001 From: Marlon Costa Date: Wed, 23 Sep 2026 21:48:14 -0300 Subject: [PATCH] fixes --- examples/__init__.py | 54 +++++++++++++++---- src/flext_cli/__init__.py | 46 +++++++++++++++- .../_base/flextclimodelsbase_part_07.py | 53 +++++++++--------- tests/__init__.py | 16 ++++-- 4 files changed, 127 insertions(+), 42 deletions(-) diff --git a/examples/__init__.py b/examples/__init__.py index 9babd61b..fdb96421 100644 --- a/examples/__init__.py +++ b/examples/__init__.py @@ -9,8 +9,23 @@ from flext_core.lazy import build_lazy_import_map, install_lazy_exports if TYPE_CHECKING: + from flext_infra import docs_main, infra + from flext_tests import ( + active_rules, + api, + discover_repository_root, + install_local_packages, + load_infra_report, + split_csv, + td, + tf, + tk, + tm, + tv, + ) + from flext_cli import cli, config, main, s, settings - from flext_core import core, d, e, h, lazy_attribute, r, services, x + from flext_core import core, d, e, h, lazy_attribute, r, x from . import _models_parts from .constants import ExamplesFlextCliConstants, c @@ -35,22 +50,34 @@ "ExamplesFlextCliTypes", "ExamplesFlextCliUtilities", "_models_parts", + "active_rules", + "api", "c", "cli", "config", "core", "d", + "discover_repository_root", + "docs_main", "e", "h", + "infra", + "install_local_packages", "lazy_attribute", + "load_infra_report", "m", "main", "p", "r", "s", - "services", "settings", + "split_csv", "t", + "td", + "tf", + "tk", + "tm", + "tv", "u", "x", ) @@ -69,15 +96,20 @@ ".typings": ("ExamplesFlextCliTypes", "t"), ".utilities": ("ExamplesFlextCliUtilities", "u"), "flext_cli": ("cli", "config", "main", "s", "settings"), - "flext_core": ( - "core", - "d", - "e", - "h", - "lazy_attribute", - "r", - "services", - "x", + "flext_core": ("core", "d", "e", "h", "lazy_attribute", "r", "x"), + "flext_infra": ("docs_main", "infra"), + "flext_tests": ( + "active_rules", + "api", + "discover_repository_root", + "install_local_packages", + "load_infra_report", + "split_csv", + "td", + "tf", + "tk", + "tm", + "tv", ), }), alias_groups=MappingProxyType({}), diff --git a/src/flext_cli/__init__.py b/src/flext_cli/__init__.py index 1fb6755f..8e43872c 100644 --- a/src/flext_cli/__init__.py +++ b/src/flext_cli/__init__.py @@ -20,14 +20,29 @@ ) if TYPE_CHECKING: + from flext_infra import docs_main, infra + from flext_tests import ( + active_rules, + api, + discover_repository_root, + install_local_packages, + load_infra_report, + split_csv, + td, + tf, + tk, + tm, + tv, + ) + from flext_core import core, d, e, h, lazy_attribute, r, x from . import services - from ._config import FlextCliConfig, config from ._settings import FlextCliSettings, settings from .api import FlextCli, cli from .base import FlextCliServiceBase, s from .cli import main + from .config import FlextCliConfig, config from .constants import FlextCliConstants, c from .models import FlextCliModels, m from .protocols import FlextCliProtocols, p @@ -85,14 +100,21 @@ "__url__", "__version__", "__version_info__", + "active_rules", + "api", "c", "cli", "config", "core", "d", + "discover_repository_root", + "docs_main", "e", "h", + "infra", + "install_local_packages", "lazy_attribute", + "load_infra_report", "m", "main", "p", @@ -100,7 +122,13 @@ "s", "services", "settings", + "split_csv", "t", + "td", + "tf", + "tk", + "tm", + "tv", "u", "x", ) @@ -108,11 +136,11 @@ _LAZY_IMPORTS = MappingProxyType( build_lazy_import_map( MappingProxyType({ - "._config": ("FlextCliConfig", "config"), "._settings": ("FlextCliSettings", "settings"), ".api": ("FlextCli", "cli"), ".base": ("FlextCliServiceBase", "s"), ".cli": ("main",), + ".config": ("FlextCliConfig", "config"), ".constants": ("FlextCliConstants", "c"), ".models": ("FlextCliModels", "m"), ".protocols": ("FlextCliProtocols", "p"), @@ -136,6 +164,20 @@ ".typings": ("FlextCliTypes", "t"), ".utilities": ("FlextCliUtilities", "u"), "flext_core": ("core", "d", "e", "h", "lazy_attribute", "r", "x"), + "flext_infra": ("docs_main", "infra"), + "flext_tests": ( + "active_rules", + "api", + "discover_repository_root", + "install_local_packages", + "load_infra_report", + "split_csv", + "td", + "tf", + "tk", + "tm", + "tv", + ), }), alias_groups=MappingProxyType({}), sort_keys=False, diff --git a/src/flext_cli/_models/_base/flextclimodelsbase_part_07.py b/src/flext_cli/_models/_base/flextclimodelsbase_part_07.py index 15f3c206..5bd65cea 100644 --- a/src/flext_cli/_models/_base/flextclimodelsbase_part_07.py +++ b/src/flext_cli/_models/_base/flextclimodelsbase_part_07.py @@ -65,32 +65,33 @@ def resolve(self) -> t.Cli.TypedExtractValue: if self.value is None: return default_value resolved_value: t.Cli.TypedExtractValue = default_value - match self.type_kind: - case c.Cli.TypeKind.STR: - resolved_str = str(self.value).strip() if self.value else "" - resolved_value = resolved_str or ( - self.default if isinstance(self.default, str) else "" - ) - case c.Cli.TypeKind.BOOL: - resolved_value = bool(self.value) - case c.Cli.TypeKind.DICT: - source_mapping = ( - self.value - if isinstance(self.value, Mapping) - else self.default - if isinstance(self.default, Mapping) - else None - ) - resolved_value = ( - { - k: t.Cli.JSON_VALUE_ADAPTER.validate_python(vv) - for k, vv in source_mapping.items() - } - if source_mapping is not None - else _EMPTY_JSON_MAPPING - ) - case _: - pass + # If-chains, not `match`: the lazy facade types `self.type_kind` as + # Unknown to pyright, which cannot prove a match exhaustive even + # though the arms cover every TypeKind member (same idiom as + # `_default_for_kind` below). + if self.type_kind == c.Cli.TypeKind.STR: + resolved_str = str(self.value).strip() if self.value else "" + resolved_value = resolved_str or ( + self.default if isinstance(self.default, str) else "" + ) + elif self.type_kind == c.Cli.TypeKind.BOOL: + resolved_value = bool(self.value) + else: + source_mapping = ( + self.value + if isinstance(self.value, Mapping) + else self.default + if isinstance(self.default, Mapping) + else None + ) + resolved_value = ( + { + k: t.Cli.JSON_VALUE_ADAPTER.validate_python(vv) + for k, vv in source_mapping.items() + } + if source_mapping is not None + else _EMPTY_JSON_MAPPING + ) return resolved_value def _default_for_kind(self) -> t.Cli.TypedExtractValue: diff --git a/tests/__init__.py b/tests/__init__.py index 45cd79db..b35cebf5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -9,13 +9,16 @@ from flext_core.lazy import build_lazy_import_map, install_lazy_exports if TYPE_CHECKING: + from flext_infra import docs_main, infra from flext_tests import ( + active_rules, api, config, + discover_repository_root, install_local_packages, load_infra_report, - services, settings, + split_csv, td, tf, tk, @@ -44,14 +47,18 @@ "TestsFlextCliSettings", "TestsFlextCliTypes", "TestsFlextCliUtilities", + "active_rules", "api", "c", "cli", "config", "core", "d", + "discover_repository_root", + "docs_main", "e", "h", + "infra", "install_local_packages", "lazy_attribute", "load_infra_report", @@ -60,8 +67,8 @@ "p", "r", "s", - "services", "settings", + "split_csv", "t", "td", "tf", @@ -86,13 +93,16 @@ ".utilities": ("TestsFlextCliUtilities", "u"), "flext_cli": ("cli", "main"), "flext_core": ("core", "d", "e", "h", "lazy_attribute", "r", "x"), + "flext_infra": ("docs_main", "infra"), "flext_tests": ( + "active_rules", "api", "config", + "discover_repository_root", "install_local_packages", "load_infra_report", - "services", "settings", + "split_csv", "td", "tf", "tk",