GitHub

API reference for Filter.

One check. run(value, ast, options) gives None or the issue; annotations describe it (expected, message, title, ...); an aborted filter stops the checks after it when it fails.

Attributes

AttributeTypeDescription
runCallable[[T_contra, AST, ParseOptions], Issue | None]
annotationsAnnotations | None = None
abortedbool = False

Functions

__init__

__init__(run, annotations=None, aborted=False) -> None
ParameterTypeDescription
runCallable[[T_contra, AST, ParseOptions], Issue | None]
annotationsAnnotations | None = None
abortedbool = False

annotate

annotate(**annotations) -> Filter[T_contra]

This filter with annotations merged over its own.

ParameterTypeDescription
annotationsobject = {}

Returns Filter[T_contra]

def annotate(self, /, **annotations: object) -> Filter[T_contra]:
    """This filter with ``annotations`` merged over its own."""
    return replace(self, annotations={**(self.annotations or {}), **annotations})

abort

abort() -> Filter[T_contra]

This filter, stopping the checks after it when it fails.

Returns Filter[T_contra]

def abort(self) -> Filter[T_contra]:
    """This filter, stopping the checks after it when it fails."""
    return replace(self, aborted=True)

and_

and_[T](other, **annotations) -> FilterGroup[T]

This check and other as one group (Effect's and).

ParameterTypeDescription
otherCheck[T]
annotationsobject = {}

Returns FilterGroup[T]

def and_[T](self: Filter[T], other: Check[T], /, **annotations: object) -> FilterGroup[T]:
    """This check and ``other`` as one group (Effect's ``and``)."""
    return FilterGroup((self, other), annotations or None)