Skip to content

Commit ebb8a40

Browse files
committed
Depreacte old methods
1 parent 17a4283 commit ebb8a40

File tree

7 files changed

+76
-4
lines changed

7 files changed

+76
-4
lines changed

docs/source/changelog.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ Changelog
44
All notable changes to this project will be documented in this file.
55

66

7+
[0.7.3] - 2025-10-08
8+
--------------------
9+
10+
Changed
11+
^^^^^^^
12+
- Added deprecated warnings to old methods to ``add``, ``add_condition``, ``add_global_filter`` and
13+
``add_global_validator`` to prepare for a later removal.
14+
15+
716
[0.7.2] - 2025-09-28
817
--------------------
918

1019
Changed
1120
^^^^^^^
12-
- Changed the way how to use the new decorator ``_condition``, ``_global_filter``, ``_global_validator`` and ``_model``.
21+
- Changed the way how to use the new declarative ``_condition``, ``_global_filter``, ``_global_validator`` and ``_model``.
1322
They should no longer be assigned to a variable, but should be set with the corresponding declarative method.
1423

1524
``_condition = [Example()]`` => ``condition(Example())``
@@ -20,7 +29,7 @@ Changed
2029

2130
``_model = Example`` => ``model(Example)``
2231

23-
The previous way is still supported, but is not recommended because it is not streightforward and could lead to confusion.
32+
The previous way is still supported, but is not recommended because it is not straightforward and could lead to confusion.
2433
The new methods also support multiple calls and also mass assignment.
2534

2635
Both of the following examples are valid and have the same effect:
@@ -56,7 +65,8 @@ Changed
5665

5766
Added
5867
^^^^^
59-
- Added comprehensive ``py.typed`` file for PEP 561 compliance, improving type checking support for mypy and other static type checkers.
68+
- Added comprehensive ``py.typed`` file for PEP 561 compliance, improving type checking support for mypy and
69+
other static type checkers.
6070
- Added ``AGENTS.md`` to document how to use this library for various ai agents.
6171

6272

flask_inputfilter/_input_filter.pyx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ cdef class InputFilter:
245245
Args:
246246
condition (BaseCondition): The condition to add.
247247
"""
248+
warnings.warn(
249+
"Using 'add_condition' is deprecated, use 'condition()' "
250+
"instead. https://leandercs.github.io/flask-inputfilter"
251+
"/options/declarative_api.html",
252+
DeprecationWarning,
253+
stacklevel=2,
254+
)
248255
self.conditions.append(condition)
249256

250257
cdef void _register_decorator_components(self):
@@ -537,6 +544,13 @@ cdef class InputFilter:
537544
copy (Optional[str]): The name of the field to copy the value
538545
from.
539546
"""
547+
warnings.warn(
548+
"Using 'add' is deprecated, use 'field()' "
549+
"instead. https://leandercs.github.io/flask-inputfilter"
550+
"/options/declarative_api.html",
551+
DeprecationWarning,
552+
stacklevel=2,
553+
)
540554
if name in self.fields:
541555
raise ValueError(f"Field '{name}' already exists.")
542556

@@ -683,6 +697,13 @@ cdef class InputFilter:
683697
Args:
684698
filter: The filter to add.
685699
"""
700+
warnings.warn(
701+
"Using 'add_global_filter' is deprecated, use 'global_filter()' "
702+
"instead. https://leandercs.github.io/flask-inputfilter"
703+
"/options/declarative_api.html",
704+
DeprecationWarning,
705+
stacklevel=2,
706+
)
686707
self.global_filters.append(filter)
687708

688709
cpdef list[BaseFilter] get_global_filters(self):
@@ -784,6 +805,13 @@ cdef class InputFilter:
784805
Args:
785806
validator (BaseValidator): The validator to add.
786807
"""
808+
warnings.warn(
809+
"Using 'add_global_validator' is deprecated, use 'global_validator()' "
810+
"instead. https://leandercs.github.io/flask-inputfilter"
811+
"/options/declarative_api.html",
812+
DeprecationWarning,
813+
stacklevel=2,
814+
)
787815
self.global_validators.append(validator)
788816

789817
cpdef list[BaseValidator] get_global_validators(self):

flask_inputfilter/conditions/base_condition.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
DeprecationWarning,
1010
stacklevel=2,
1111
)
12+
13+
from flask_inputfilter.models import BaseCondition

flask_inputfilter/filters/base_filter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
DeprecationWarning,
1010
stacklevel=2,
1111
)
12+
13+
from flask_inputfilter.models import BaseFilter

flask_inputfilter/input_filter.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ def add_condition(self, condition: BaseCondition) -> None:
211211
Args:
212212
condition (BaseCondition): The condition to add.
213213
"""
214+
warnings.warn(
215+
"Using 'add_condition' is deprecated, use 'condition()' "
216+
"instead. https://leandercs.github.io/flask-inputfilter"
217+
"/options/declarative_api.html",
218+
DeprecationWarning,
219+
stacklevel=2,
220+
)
214221
self.conditions.append(condition)
215222

216223
def _register_decorator_components(self) -> None:
@@ -497,6 +504,13 @@ def add(
497504
copy (Optional[str]): The name of the field to copy the value
498505
from.
499506
"""
507+
warnings.warn(
508+
"Using 'add' is deprecated, use 'field()' "
509+
"instead. https://leandercs.github.io/flask-inputfilter"
510+
"/options/declarative_api.html",
511+
DeprecationWarning,
512+
stacklevel=2,
513+
)
500514
if name in self.fields:
501515
raise ValueError(f"Field '{name}' already exists.")
502516

@@ -643,6 +657,13 @@ def add_global_filter(self, filter: BaseFilter) -> None:
643657
Args:
644658
filter: The filter to add.
645659
"""
660+
warnings.warn(
661+
"Using 'add_global_filter' is deprecated, use 'global_filter()' "
662+
"instead. https://leandercs.github.io/flask-inputfilter"
663+
"/options/declarative_api.html",
664+
DeprecationWarning,
665+
stacklevel=2,
666+
)
646667
self.global_filters.append(filter)
647668

648669
def get_global_filters(self) -> list[BaseFilter]:
@@ -745,6 +766,13 @@ def add_global_validator(self, validator: BaseValidator) -> None:
745766
Args:
746767
validator (BaseValidator): The validator to add.
747768
"""
769+
warnings.warn(
770+
"Using 'add_global_validator' is deprecated, use 'global_validator()' "
771+
"instead. https://leandercs.github.io/flask-inputfilter"
772+
"/options/declarative_api.html",
773+
DeprecationWarning,
774+
stacklevel=2,
775+
)
748776
self.global_validators.append(validator)
749777

750778
def get_global_validators(self) -> list[BaseValidator]:

flask_inputfilter/validators/base_validator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
DeprecationWarning,
1010
stacklevel=2,
1111
)
12+
13+
from flask_inputfilter.models import BaseValidator

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "flask_inputfilter"
7-
version = "0.7.2"
7+
version = "0.7.3"
88
description = "A library to easily filter and validate input data in Flask applications"
99
readme = "README.md"
1010
keywords = [

0 commit comments

Comments
 (0)