Source code for form.types

from typing import Any, Literal, Protocol, TypeVar, TYPE_CHECKING
if TYPE_CHECKING:
    from collections.abc import Callable, Iterable, Sequence
    from decimal import Decimal
    from onegov.form import Form
    from webob.request import _FieldStorageWithFile
    from wtforms.fields.core import _Filter, _Validator, _Widget, Field
    from wtforms.fields.choices import SelectChoice
    from wtforms.form import BaseForm

[docs] class FieldCondition[BaseFormT: BaseForm, FieldT: Field](Protocol):
[docs] def __call__(self, form: BaseFormT, field: FieldT, /) -> bool: ...
type Widget[T: Field] = _Widget[T] type Filter = _Filter type BaseValidator[ FormT: BaseForm, FieldT: Field ] = _Validator[FormT, FieldT] # validator is slightly more specific in that it expects our Form type type Validator[FormT: Form, FieldT: Field] = _Validator[FormT, FieldT] type Validators[ FormT: Form, FieldT: Field ] = tuple[_Validator[FormT, FieldT], ...] | list[Any] type RawPricing = ( tuple[Decimal | float, str] | tuple[Decimal | float, str, bool] ) type PricingRules = dict[str | range, RawPricing] # this matches what webob.request.POST returns as value type type RawFormValue = str | _FieldStorageWithFile type SelectChoicesCallback[FieldT: Field] = ( Callable[[Any, FieldT], Sequence[SelectChoice]] | Callable[[], Sequence[SelectChoice]] ) type SelectChoices[FieldT: Field] = ( Iterable[SelectChoice] | SelectChoicesCallback[FieldT] )
[docs] type SubmissionState = Literal['pending', 'complete']
[docs] type RegistrationState = Literal[ 'open', 'cancelled', 'confirmed', 'partial' ]
[docs] FormT = TypeVar('FormT', bound='Form', contravariant=True)
[docs] FieldT = TypeVar('FieldT', bound='Field', contravariant=True)