Skip to content

Filters

predicate

Predicate

Bases: ABC

Base class for filter predicates that serialize to VNDB's filter DSL.

to_filter abstractmethod

to_filter() -> list[Any]

Serialize this predicate to VNDB's nested-list filter form.

Comparison

Comparison(name: str, op: str, value: Any)

Bases: Predicate

A single [field, op, value] predicate.

Compound

Compound(kind: str, predicates: list[Predicate])

Bases: Predicate

An ["and"|"or", ...] predicate.

Field

Field(name: str)

A filterable field; comparison operators build :class:Comparisons.

Because &/| bind looser than comparison operators in Python, wrap each comparison in parentheses when composing: (f.rating >= 80) & (f.lang == "en").

Instances are immutable: namespace fields (e.g. vn_filters.rating) are shared singletons, so rebinding .name is blocked to avoid corrupting them globally.

resolve_filters

resolve_filters(
    filters: Predicate | list[Any] | str | None,
) -> list[Any] | str | None

Serialize a :class:Predicate to its list form; pass raw lists, compact strings, and None through unchanged.

namespaces

field

field(name: str) -> Field

Build a :class:Field for an arbitrary VNDB filter name (escape hatch).