GitHub

TransportError

API reference for TransportError.

No GraphQL response came: a network failure, an HTTP response that is not GraphQL or a non-2xx GraphQL response without errors (status and headers set), or a closed WebSocket (close_code). fatal marks a failure retrying cannot fix; cause is the original error.

Attributes

AttributeTypeDescription
descriptionstr
statusint | None = S.field(S.Union(S.Int, Undefined), default=None)
headersHeaders | None = S.field(S.Union(HEADERS, Undefined), default=None)
retry_afterDuration | None = S.field(S.Union(S.DurationFromMillis, Undefined), default=None, key='retryAfter')
close_codeint | None = S.field(S.Union(S.Int, Undefined), default=None, key='closeCode')
fatalbool | None = S.field(S.Union(S.Boolean, Undefined), default=None)
causeobject = S.field(S.Union(S.Defect(), Undefined), default=None)
is_retryablebool

A network failure, status 429 or 5xx, a retry_after, or a close code that is not fatal; never when fatal.

messagestr

Functions

from_http_client_error

from_http_client_error(error, *, now_millis=None) -> TransportError

error with the response's status, headers and Retry-After (an HTTP date measured from now_millis, by default the wall clock).

ParameterTypeDescription
errorhttp_error.HttpClientError
now_millisfloat | None = None

Returns TransportError

@staticmethod
def from_http_client_error(
    error: http_error.HttpClientError, *, now_millis: float | None = None
) -> TransportError:
    """``error`` with the response's ``status``, ``headers`` and
    ``Retry-After`` (an HTTP date measured from ``now_millis``, by
    default the wall clock)."""
    response = error.response
    headers = None if response is None else response.headers
    now = time.time_ns() // 1_000_000 if now_millis is None else now_millis
    return TransportError(
        description=error.message,
        status=None if response is None else response.status,
        headers=headers,
        retry_after=parse_retry_after_header(
            None if headers is None else headers.get("retry-after"), now
        ),
        cause=error,
    )

fields

fields() -> Mapping[str, Bottom[object, object, Never, Never]]

Each field's schema, the tag's first in a tagged class.

Returns Mapping[str, Bottom[object, object, Never, Never]]

@classmethod
def fields(cls) -> Mapping[str, Bottom[object, object, Never, Never]]:
    """Each field's schema, the tag's first in a tagged class."""
    shape = _shape_of(cls)
    schemas = shape.schemas
    if shape.tag is None:
        return dict(schemas)
    tag: Bottom[object, object, Never, Never] = Bottom(ast.Literal(shape.tag))
    return {"_tag": tag, **schemas}

make

make(input, **options) -> Self

input checked against the class's schema (its checks included); raises SchemaError. Construct with cls(...); an instance is kept as it is.

ParameterTypeDescription
inputSelf
optionsUnpack[ParseOptions] = {}

Returns Self

@classmethod
def make(cls, input: Self, /, **options: Unpack[ParseOptions]) -> Self:
    """``input`` checked against the class's schema (its checks
    included); raises ``SchemaError``. Construct with ``cls(...)``; an
    instance is kept as it is."""
    shape = _shape_of(cls)
    return make_class_sync(
        cls.ast.to_type(),
        input,
        options,
        lambda fields: cast("Self", shape.construct(dict(fields))),
    )

make_option

make_option(input, **options) -> Option[Self]
ParameterTypeDescription
inputSelf
optionsUnpack[ParseOptions] = {}

Returns Option[Self]

@classmethod
def make_option(cls, input: Self, /, **options: Unpack[ParseOptions]) -> Option[Self]:
    return cls.__codec__().make_option(input, **options)

make_effect

make_effect(input, **options) -> Effect[Self, Issue]
ParameterTypeDescription
inputSelf
optionsUnpack[ParseOptions] = {}

Returns Effect[Self, Issue]

@classmethod
def make_effect(cls, input: Self, /, **options: Unpack[ParseOptions]) -> Effect[Self, Issue]:
    return cls.__codec__().make_effect(input, **options)

annotate

annotate(**annotations) -> Bottom[Self, Mapping[str, object]]

The class's schema with annotations (a new schema, not a class).

ParameterTypeDescription
annotationsobject = {}

Returns Bottom[Self, Mapping[str, object]]

@classmethod
def annotate(cls, /, **annotations: object) -> Bottom[Self, Mapping[str, object]]:
    """The class's schema with annotations (a new schema, not a class)."""
    return cls.__codec__().annotate(**annotations)

check

check(first, *rest) -> Bottom[Self, Mapping[str, object]]

The class's schema with checks (a new schema, not a class).

ParameterTypeDescription
firstCheck[Self]
restCheck[Self] = ()

Returns Bottom[Self, Mapping[str, object]]

@classmethod
def check(cls, first: Check[Self], /, *rest: Check[Self]) -> Bottom[Self, Mapping[str, object]]:
    """The class's schema with checks (a new schema, not a class)."""
    return cls.__codec__().check(first, *rest)

pipe

pipe[B](f) -> B
ParameterTypeDescription
fCallable[[type[Self]], B]

Returns B

@classmethod
def pipe[B](cls, f: Callable[[type[Self]], B], /) -> B:
    return f(cls)