Skip to main content

CQL2 JSON Pydantic

PyPI - Version PyPI - Python Version GitHub Actions Workflow Status Code coverage

Pydantic v2 models for building CQL2 JSON filters.

Quick start

pip install cql2json-pydantic
from cql2json_pydantic import BinaryComparisonPredicate, BinaryComparisonPredicateOp, PropertyRef

query = BinaryComparisonPredicate(
    op=BinaryComparisonPredicateOp.EQUAL,
    args=[PropertyRef(property="city"), "Toronto"],
)
print(query.model_dump_json(exclude_none=True))

Output:

{"op":"=","args":[{"property":"city"},"Toronto"]}

Use model_dump_json(indent=2, exclude_none=True) for formatted JSON, or model_dump(mode="json", exclude_none=True) for a JSON-compatible Python dictionary.

See more filter examples and their JSON output.

GeoJSON models accept coordinates directly as lists or tuples:

import cql2json_pydantic as cql

point = cql.Point((-115.81, 37.24))
line = cql.Linestring(((0, 0), (1, 1)))
polygon = cql.Polygon([[(0, 0), (1, 0), (1, 1), (0, 0)]])
points = cql.Multipoint(((0, 0), (1, 1)))
lines = cql.Multilinestring([[(0, 0), (1, 1)]])
polygons = cql.Multipolygon([[[(0, 0), (1, 0), (1, 1), (0, 0)]]])
collection = cql.Geometrycollection((point, line))

Keyword construction such as cql.Point(coordinates=[-115.81, 37.24]) remains supported, as do existing coordinate wrapper models. Additional fields are keyword arguments, for example cql.Point((0, 0), bbox=[-1, -1, 1, 1]). These remain Pydantic models with the same validation and serialization methods.

Project conventions

This project is templated a Hatch-based Python package with:

  • Apache-2.0 license
  • Keep a Changelog-compatible CHANGELOG.md
  • Diátaxis documentation under docs/
  • top-level mkdocs.yaml
  • Taskfile integration with Terradue/taskfile-utils
  • GitHub Actions CI

Documentation

Project documentation: https://terradue.github.io/cql2json-pydantic/

Contribute

Submit a Github issue if you have comments or suggestions.

Local quality checks

Install Hatch and Taskfiles then install the Git hook:

task quality:pre-commit:install

Every commit runs Ruff (including the configured McCabe complexity limit), Ruff formatting, strict mypy checks, and the pytest suite.

Run the complete hook explicitly with:

task quality:pre-commit:run

License

Apache License, Version 2.0

Metadata

Release files for cql2json-pydantic 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cql2json-pydantic 0.2.0
File Size Uploaded Provenance Actions
cql2json_pydantic-0.2.0.tar.gz 33.2 kB With provenance Details for cql2json_pydantic-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cql2json-pydantic 0.2.0
File Interpreter ABI Platform Actions
cql2json_pydantic-0.2.0-py3-none-any.whl Python 3 none any Details for cql2json_pydantic-0.2.0-py3-none-any.whl

Total release size: 45.4 kB

Release files / cql2json_pydantic-0.2.0.tar.gz

Download URL cql2json_pydantic-0.2.0.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6e5d334fc46f5a09e2d62a88a0c80d68679ae10638ada8f38ec3d073412d3abc
BLAKE2b-256 checksum
How to use checksums
64598e6c1c82f24c4b875b497129695e9d41382079ea5840cb329f7bef5bd87e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / cql2json_pydantic-0.2.0-py3-none-any.whl

Download URL cql2json_pydantic-0.2.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2eb2f344a23fe44558f8535a02ae24d847f62a77381dac87a330bdd67c1aa46b
BLAKE2b-256 checksum
How to use checksums
35296abdfc2683288c17d95118c5097e4dff6e2bbec51c521b30dcc3e5ff4c20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Security for cql2json-pydantic 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cql2json_pydantic-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page