Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,61 @@
name: lint

on: [push]
on:
push:
branches:
- main
tags:
- '**'
pull_request: {}

jobs:
ruff-format:
name: Check code formatting with Ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5

- name: Set up Python 3.14
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: '3.13'
python-version: '3.14'

- name: Install dependencies
run: |
pip install uv
uv pip sync --system requirements/requirements.txt requirements/requirements-dev.txt
run: uv sync --group dev

- name: Run Ruff formatter
run: ruff format --diff
run: uv run ruff format --diff

ruff-check:
name: Check code linting with Ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5

- name: Set up Python 3.14
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: '3.13'
python-version: '3.14'

- name: Install dependencies
run: |
pip install uv
uv pip sync --system requirements/requirements.txt requirements/requirements-dev.txt
run: uv sync --group dev

- name: Run Ruff formatter
run: ruff check --output-format=github
run: uv run ruff check --output-format=github

typecheck:
name: Run typechecking with pyright
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.14
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: '3.14'

- name: Install dependencies
run: uv sync --group dev

- name: Run pyright
run: uv run pyright
63 changes: 28 additions & 35 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,57 @@
name: tests

on: [push]
on:
push:
branches:
- main
tags:
- '**'
pull_request: {}

jobs:
typecheck:
name: Run typechecking with pyright
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
- 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:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install uv
uv pip sync --system requirements/requirements.txt requirements/requirements-test.txt
- name: Install tox
run: uv tool install --managed-python --python 3.13 tox --with tox-uv --with tox-gh
- name: Install Python ${{ matrix.python-version }}
run: uv python install --managed-python ${{ matrix.python-version }}
- name: Test with tox
run: tox
run: tox run
env:
TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }}
UV_PYTHON_DOWNLOADS: never

docs:
name: Build and check documentation
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5

- name: Set up Python 3.14
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: '3.13'
python-version: '3.14'

- name: Install dependencies
run: |
pip install uv
uv pip sync --system requirements/requirements.txt requirements/requirements-docs.txt
run: uv sync --group docs

- name: Lint docs with sphinx-lint
run: |
sphinx-lint docs
uv run sphinx-lint docs

- name: Build docs and check the integrity of external links
run: |
sphinx-build --builder linkcheck --fail-on-warning "source" "build"
sphinx-build --builder html --fail-on-warning "source" "build"
uv run sphinx-build --builder linkcheck --fail-on-warning "source" "build"
uv run sphinx-build --builder html --fail-on-warning "source" "build"
working-directory:
./docs
4 changes: 0 additions & 4 deletions docs/requirements-rtd.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docs/source/usage/typechecking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Representing types

The :mod:`jsonlogic.json_schema.types` module defines a fixed representation of the possible
JSON Schema types. The primitive types are represented (e.g. :class:`~jsonlogic.json_schema.types.BooleanType`),
but the module supports `formats <https://json-schema.org/understanding-json-schema/reference/string#format>`_
but the module supports `formats <https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.7.2>`_
to allow operators to work with specific other types (e.g. ``"date"`` and ``"date-time"``).

Compound types
Expand Down
66 changes: 51 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,66 @@
[build-system]
requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "python-jsonlogic"
description = "An extensible and sane implementation of JsonLogic"
version = "0.1.0"
description = "An extensible and sane implementation of JsonLogic"
readme = "README.rst"
authors = [
{name = "Victorien", email = "contact@vctrn.dev"}
]
license = 'MIT'
license-files = ['LICENSE']
requires-python = ">=3.10"
classifiers = [
"Development Status :: 4 - Beta",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Typing :: Typed",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
]
license = {file = "LICENSE"}
requires-python = ">=3.8"
dependencies = [
"typing-extensions>=4.10.0; python_version < '3.13'",
]

[tool.setuptools]
package-dir = {"" = "src"}
[dependency-groups]
dev = [
"pyright",
"ruff",
"pytest>=8.4.0",
"tomli",
"ruff>=0.11.3",
"tox>=4.25.0",
"tox-gh>=1.5.0",
"tox-uv>=1.25.0",
]
docs = [
"furo",
"sphinx",
"sphinx-lint",
"sphinx-paramlinks",
]


[tool.setuptools.packages.find]
where = ["src"]
[tool.hatch.build.targets.wheel]
packages = ["src/jsonlogic"]

[tool.setuptools.package-data]
"jsonlogic" = ["py.typed"]
[tool.uv]
default-groups = ['dev']
required-version = ">=0.9.0"

[tool.ruff]
line-length = 120
src = ["src"]
target-version = "py39"
target-version = "py310"
line-length = 120

[tool.ruff.lint]
typing-modules = ["jsonlogic._compat"]
Expand Down Expand Up @@ -78,3 +95,22 @@ known-first-party = ["jsonlogic"]

[tool.pytest.ini_options]
pythonpath = "src"

[tool.tox]
requires = ["tox>=4.21"]
env_list = ["py310", "py311", "py312", "py314"]

[tool.tox.env_run_base]
description = "Run test under {base_python}"
runner = "uv-venv-lock-runner"
dependency_groups = ["dev"]
uv_python_preference = "only-managed"
uv_sync_flags = ["--no-python-downloads"]
commands = [["pytest"]]

[tool.tox.gh.python]
"3.10" = ["py310"]
"3.11" = ["py311"]
"3.12" = ["py312"]
"3.13" = ["py313"]
"3.14" = ["py314"]
27 changes: 15 additions & 12 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# See https://docs.readthedocs.com/platform/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
os: ubuntu-24.04
tools:
python: "3.12"
python: "3.14"
# https://docs.readthedocs.com/platform/stable/build-customization.html#install-dependencies-with-uv
jobs:
pre_create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
create_environment:
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
install:
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
- epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements-rtd.txt
- pdf
- epub
7 changes: 3 additions & 4 deletions src/jsonlogic/_compat.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import sys

if sys.version_info >= (3, 13):
from types import NoneType
from typing import Self, TypeAlias, TypeIs, TypeVarTuple, Unpack
else:
from typing_extensions import Self, TypeAlias, TypeIs, TypeVarTuple, Unpack
from typing import TypeAlias

NoneType = type(None)
from typing_extensions import Self, TypeIs, TypeVarTuple, Unpack


__all__ = ("NoneType", "Self", "TypeAlias", "TypeIs", "TypeVarTuple", "Unpack")
__all__ = ("Self", "TypeAlias", "TypeIs", "TypeVarTuple", "Unpack")
7 changes: 4 additions & 3 deletions src/jsonlogic/evaluation/evaluation_settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from collections.abc import Callable
from dataclasses import dataclass, field
from datetime import date, datetime
from typing import Any, Callable, TypedDict
from typing import Any, TypedDict

from jsonlogic._compat import Self
from jsonlogic.resolving import PointerReferenceParser, ReferenceParser
Expand Down Expand Up @@ -37,7 +38,7 @@ class EvaluationSettings:

Default: :python:`{"date": date.fromisoformat, "date-time": datetime.fromisoformat}`.

.. _JSON Schema formats: https://json-schema.org/understanding-json-schema/reference/string#built-in-formats
.. _JSON Schema formats: https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.7.2
"""

literal_casts: list[Callable[[str], Any]] = field(default_factory=list)
Expand Down Expand Up @@ -83,7 +84,7 @@ class EvaluationSettingsDict(TypedDict, total=False):

Default: :python:`{"date": date.fromisoformat, "date-time": datetime.fromisoformat}`.

.. _JSON Schema formats: https://json-schema.org/understanding-json-schema/reference/string#built-in-formats
.. _JSON Schema formats: https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.7.2
"""

literal_casts: list[Callable[[str], Any]]
Expand Down
3 changes: 2 additions & 1 deletion src/jsonlogic/evaluation/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import Any, Callable
from collections.abc import Callable
from typing import Any

from jsonlogic.core import Operator
from jsonlogic.typing import JSON, JSONLogicPrimitive, OperatorArgument
Expand Down
Loading
Loading