diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0271a15..b24fe40 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -23,7 +23,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -r requirements.txt + python -m pip install -r cutekit/requirements.txt python -m pip install mypy pytest ruff - name: Type Checking diff --git a/cutekit/builder.py b/cutekit/builder.py index bac082e..d884099 100644 --- a/cutekit/builder.py +++ b/cutekit/builder.py @@ -96,7 +96,7 @@ class ProductScope(ComponentScope): Compute = Callable[[TargetScope], list[str]] _vars: dict[str, Compute] = {} -Hook = Callable[[ComponentScope], None] +Hook = Callable[[TargetScope], None] _hooks: dict[str, Hook] = {} diff --git a/cutekit/const.py b/cutekit/const.py index e9e2a90..2d93d4a 100644 --- a/cutekit/const.py +++ b/cutekit/const.py @@ -14,8 +14,10 @@ def __bool__(self): raise Exception("Uninitialized constant") -VERSION = (0, 7, 0, "dev") -VERSION_STR = f"{VERSION[0]}.{VERSION[1]}.{VERSION[2]}{'-' + VERSION[3] if len(VERSION) >= 4 else ''}" +VERSION = (0, 7, 0, "") +VERSION_STR = ( + f"{VERSION[0]}.{VERSION[1]}.{VERSION[2]}{'-' + VERSION[3] if VERSION[3] else ''}" +) MODULE_DIR = os.path.dirname(os.path.realpath(__file__)) diff --git a/cutekit/export.py b/cutekit/export.py index c1a6a9c..ee8e28a 100644 --- a/cutekit/export.py +++ b/cutekit/export.py @@ -1,6 +1,5 @@ import os import json -import html from typing import Any, Optional from . import model, cli, vt100, jexpr, const diff --git a/cutekit/jexpr.py b/cutekit/jexpr.py index 026f3d4..9c2caa2 100644 --- a/cutekit/jexpr.py +++ b/cutekit/jexpr.py @@ -69,7 +69,7 @@ def _expand(expr: Jexpr) -> Jexpr: result: dict[str, Jexpr] = {} for k in expr: key = _expand(k) - result[key] = _expand(expr[k]) + result[str(key)] = _expand(expr[k]) return result elif _isListExpr(expr): @@ -80,7 +80,7 @@ def _expand(expr: Jexpr) -> Jexpr: raise ValueError(f"Expected string, got {expr[0]}") fName = _expand(expr[0][1:]) - fVal = eval(fName, globals, locals) + fVal = eval(str(fName), globals, locals) res = fVal(*_expand(expr[1:])) return _expand(res) @@ -90,8 +90,8 @@ def _expand(expr: Jexpr) -> Jexpr: elif isinstance(expr, str): return _extractStr( expr, - lambda e: eval(e, globals, locals) - if not (e.startswith("{") and e.endswith("}")) + lambda e: eval(str(e), globals, locals) + if not (isinstance(e, str) and e.startswith("{") and e.endswith("}")) else e, ) diff --git a/cutekit/model.py b/cutekit/model.py index 398ba17..cb42e41 100644 --- a/cutekit/model.py +++ b/cutekit/model.py @@ -578,13 +578,10 @@ class Registry(DataClassJsonMixin): project: Project manifests: dict[str, Manifest] = dt.field(default_factory=dict) - def _append(self, m: Optional[Manifest]) -> Optional[Manifest]: + def _append(self, m: Manifest) -> Manifest: """ Append a manifest to the model """ - if m is None: - return m - if m.id in self.manifests: raise RuntimeError( f"Duplicated manifest '{m.id}' at '{m.path}' already loaded from '{self.manifests[m.id].path}'" diff --git a/tests/test_cli.py b/tests/test_cli.py index 06be5d6..de2f1ab 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -250,7 +250,7 @@ def test_cli_extra_args(): class StrOperandArg: - value: str = cli.operand(None, "value") + value: str = cli.operand("value") def test_cli_operand_args(): @@ -259,7 +259,7 @@ def test_cli_operand_args(): class ListOperandArg: - value: list[str] = cli.operand(None, "value") + value: list[str] = cli.operand("value") def test_cli_operand_list_args():