diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7eb386c..235a6f5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,7 +3,23 @@ name: tests on: [push] jobs: - test: + typecheck: + name: Run typechecking with pyright + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install dependencies + run: | + pip install uv + uv pip sync --system requirements/requirements.txt requirements/requirements-test.txt + - name: Run pyright + run: pyright + +test: name: Run tests with pytest runs-on: ubuntu-latest strategy: diff --git a/pyproject.toml b/pyproject.toml index 531975b..7afa564 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ license = {file = "LICENSE"} requires-python = ">=3.8" dependencies = [ - "typing-extensions>=4.0.1; python_version < '3.10'", + "typing-extensions>=4.10.0; python_version < '3.13'", ] [tool.setuptools] diff --git a/requirements/requirements-dev.in b/requirements/requirements-dev.in index c5c9570..ca9b1d8 100644 --- a/requirements/requirements-dev.in +++ b/requirements/requirements-dev.in @@ -1,2 +1,3 @@ -c requirements.txt +pyright ruff diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index 9a415cc..57686b0 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -4,5 +4,12 @@ # # pip-compile requirements/requirements-dev.in # +nodeenv==1.8.0 + # via pyright +pyright==1.1.360 + # via -r requirements/requirements-dev.in ruff==0.3.2 # via -r requirements/requirements-dev.in + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/src/jsonlogic/core.py b/src/jsonlogic/core.py index 4790382..4953ca3 100644 --- a/src/jsonlogic/core.py +++ b/src/jsonlogic/core.py @@ -81,7 +81,7 @@ class JSONLogicExpression: expression: JSONLogicPrimitive | NormalizedExpression @classmethod - def from_json(cls, json: JSON) -> Self: # TODO disallow list? + def from_json(cls, json: JSON) -> Self: # TODO disallow list? TODO fix type errors """Build a JSON Logic expression from JSON data. Operator arguments are recursively normalized to a :class:`list`:: @@ -90,7 +90,7 @@ def from_json(cls, json: JSON) -> Self: # TODO disallow list? assert expr.expression == {"var": ["varname"]} """ if not isinstance(json, dict): - return cls(expression=json) + return cls(expression=json) # type: ignore operator, op_args = next(iter(json.items())) if not isinstance(op_args, list): @@ -98,7 +98,7 @@ def from_json(cls, json: JSON) -> Self: # TODO disallow list? sub_expressions = [cls.from_json(op_arg) for op_arg in op_args] - return cls({operator: sub_expressions}) + return cls({operator: sub_expressions}) # type: ignore def as_operator_tree(self, operator_registry: OperatorRegistry) -> JSONLogicPrimitive | Operator: """Return a recursive tree of operators, using the provided registry as a reference.