diff --git a/pyproject.toml b/pyproject.toml index 36dd7e09..d27a44f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ dependencies = [ 'typing_extensions', 'werkzeug', 'WTForms-SQLAlchemy', - 'WTForms>=3.0', + 'WTForms>=3.1', ] diff --git a/src/baseframe/forms/fields.py b/src/baseframe/forms/fields.py index 403a1417..ce8b0a02 100644 --- a/src/baseframe/forms/fields.py +++ b/src/baseframe/forms/fields.py @@ -451,7 +451,7 @@ def iter_choices(self) -> ReturnIterChoices: """Iterate over choices.""" if self.data: for user in self.data: - yield (user.userid, user.pickername, True) + yield (user.userid, user.pickername, True, {}) def process_formdata(self, valuelist: t.List[str]) -> None: """Process incoming data from request form.""" @@ -503,7 +503,7 @@ def _value(self) -> str: def iter_choices(self) -> ReturnIterChoices: """Iterate over choices.""" if self.data: - yield (self.data.userid, self.data.pickername, True) + yield (self.data.userid, self.data.pickername, True, {}) def process_formdata(self, valuelist: t.List[str]) -> None: """Process incoming data from request form.""" @@ -546,7 +546,7 @@ def iter_choices(self) -> ReturnIterChoices: """Iterate over choices.""" if self.data: for user in self.data: - yield (str(user), str(user), True) + yield (str(user), str(user), True, {}) def process_formdata(self, valuelist: t.List[str]) -> None: """Process incoming data from request form.""" @@ -616,10 +616,10 @@ def iter_choices(self) -> ReturnIterChoices: """Iterate over choices.""" if self.data: if isinstance(self.data, (str, GeonameidProtocol)): - yield (str(self.data), str(self.data), True) + yield (str(self.data), str(self.data), True, {}) else: for item in self.data: - yield (str(item), str(item), True) + yield (str(item), str(item), True, {}) def process_formdata(self, valuelist: t.List[str]) -> None: """Process incoming data from request form.""" @@ -883,7 +883,7 @@ def iter_choices(self) -> ReturnIterChoices: """Iterate over choices.""" selected_name = self.lenum[self.data].name if self.data is not None else None for name, title in self.choices: - yield (name, title, name == selected_name) + yield (name, title, name == selected_name, {}) def process_data(self, value: t.Any) -> None: """Process incoming data from Python.""" diff --git a/src/baseframe/forms/typing.py b/src/baseframe/forms/typing.py index 4517da7f..ba423df2 100644 --- a/src/baseframe/forms/typing.py +++ b/src/baseframe/forms/typing.py @@ -8,7 +8,9 @@ FilterCallable: te.TypeAlias = t.Callable[[t.Any], t.Any] FilterList: te.TypeAlias = t.Iterable[FilterCallable] -ReturnIterChoices: te.TypeAlias = t.Generator[t.Tuple[str, str, bool], None, None] +ReturnIterChoices: te.TypeAlias = t.Generator[ + t.Tuple[str, str, bool, t.Dict[str, t.Any]], None, None +] ValidatorCallable: te.TypeAlias = t.Callable[[WTForm, WTField], None] ValidatorList: te.TypeAlias = t.Sequence[ValidatorCallable] ValidatorConstructor: te.TypeAlias = t.Callable[..., ValidatorCallable] diff --git a/src/baseframe/forms/widgets.py b/src/baseframe/forms/widgets.py index 4e45525a..23b8f1c3 100644 --- a/src/baseframe/forms/widgets.py +++ b/src/baseframe/forms/widgets.py @@ -73,8 +73,8 @@ def __call__(self, field: WTField, **kwargs: t.Any) -> Markup: kwargs['class'] = 'select2' html = [f'') return Markup(''.join(html))