Skip to content

Commit

Permalink
Merge pull request #859 from azmeuk/deprecations
Browse files Browse the repository at this point in the history
remove deprecations for 3.2
  • Loading branch information
azmeuk authored Oct 11, 2024
2 parents 549a61a + b7d54ab commit b0a58f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ Unreleased
- :class:`~wtforms.validators.NoneOf` and :class:`~wtforms.validators.AnyOf`
can validate multiple valued fields like :class:`~fields.SelectMultipleField`
:pr:`538` :pr:`807`
- ⚠️Breaking change⚠️: Some deprecated code was removed (:pr:`859`):

- Breaking change: The key for form errors moved from :data:`None` to
- :class:`~wtforms.Flags` can no longer be tuples. :issue:`467`
- `iter_choices` needs a tuple of 4 items :issue:`816`

- ⚠️Breaking change⚠️: The key for form errors moved from :data:`None` to
empty string `""`. :issue:`829` :pr:`858`

.. note::
Expand Down
12 changes: 0 additions & 12 deletions src/wtforms/fields/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import inspect
import itertools
import warnings

from markupsafe import escape
from markupsafe import Markup
Expand Down Expand Up @@ -131,17 +130,6 @@ def __init__(
for v in itertools.chain(self.validators, [self.widget]):
flags = getattr(v, "field_flags", {})

# check for legacy format, remove eventually
if isinstance(flags, tuple): # pragma: no cover
warnings.warn(
"Flags should be stored in dicts and not in tuples. "
"The next version of WTForms will abandon support "
"for flags in tuples.",
DeprecationWarning,
stacklevel=2,
)
flags = {flag_name: True for flag_name in flags}

for k, v in flags.items():
setattr(self.flags, k, v)

Expand Down
26 changes: 2 additions & 24 deletions src/wtforms/widgets/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

from markupsafe import escape
from markupsafe import Markup

Expand Down Expand Up @@ -368,32 +366,12 @@ def __call__(self, field, **kwargs):
optgroup_params = html_params(label=group)
html.append(f"<optgroup {optgroup_params}>")
for choice in choices:
if len(choice) == 4:
val, label, selected, render_kw = choice
else:
warnings.warn(
"'iter_groups' is expected to return 4 items tuple since "
"wtforms 3.1, this will be mandatory in wtforms 3.2",
DeprecationWarning,
stacklevel=2,
)
val, label, selected = choice
render_kw = {}
val, label, selected, render_kw = choice
html.append(self.render_option(val, label, selected, **render_kw))
html.append("</optgroup>")
else:
for choice in field.iter_choices():
if len(choice) == 4:
val, label, selected, render_kw = choice
else:
warnings.warn(
"'iter_choices' is expected to return 4 items tuple since "
"wtforms 3.1, this will be mandatory in wtforms 3.2",
DeprecationWarning,
stacklevel=2,
)
val, label, selected = choice
render_kw = {}
val, label, selected, render_kw = choice
html.append(self.render_option(val, label, selected, **render_kw))
html.append("</select>")
return Markup("".join(html))
Expand Down

0 comments on commit b0a58f9

Please sign in to comment.