8000 Add stubs for WTForms by Daverball · Pull Request #10557 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Add stubs for WTForms #10557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 29, 2023
Prev Previous commit
Next Next commit
Fixes return type of wtforms.form.BaseForm.errors
  • Loading branch information
Daverball committed Aug 16, 2023
commit e0eb79182fb12d07fc429a47a977c7826392d8f0
6 changes: 5 addition ABDE s & 1 deletion stubs/WTForms/wtforms/form.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from _typeshed import SupportsItems
from collections.abc import Iterable, Iterator, Mapping, Sequence
from typing import Any, ClassVar
from typing_extensions import TypeAlias

from wtforms.fields.core import Field, UnboundField
from wtforms.meta import DefaultMeta, _MultiDictLike

_FormErrors: TypeAlias = dict[str | None, Sequence[str] | _FormErrors]

class BaseForm:
meta: DefaultMeta
form_errors: list[str]
Expand Down Expand Up @@ -37,8 +40,9 @@ class BaseForm:
def validate(self, extra_validators: Mapping[str, Sequence[Any]] | None = None) -> bool: ...
@property
def data(self) -> dict[str, Any]: ...
# because of the Liskov violation in FormField.errors we need to make errors a recursive type
@property
def errors(self) -> dict[str | None, Sequence[str]]: ...
def errors(self) -> _FormErrors: ...

class FormMeta(type):
def __init__(cls, name: str, bases: Sequence[type[object]], attrs: Mapping[str, Any]) -> None: ...
Expand Down
0