Skip to content

Commit 53ba798

Browse files
committed
Depreacte old methods
1 parent 17a4283 commit 53ba798

File tree

7 files changed

+78
-4
lines changed

7 files changed

+78
-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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import json
1515
import logging
1616
import sys
1717
from typing import Any, Optional, Type, TypeVar, Union
18+
import warnings
1819

1920
from flask import Response, g, request
2021

@@ -245,6 +246,13 @@ cdef class InputFilter:
245246
Args:
246247
condition (BaseCondition): The condition to add.
247248
"""
249+
warnings.warn(
250+
"Using 'add_condition' is deprecated, use 'condition()' "
251+
"instead. https://leandercs.github.io/flask-inputfilter"
252+
"/options/declarative_api.html",
253+
DeprecationWarning,
254+
stacklevel=2,
255+
)
248256
self.conditions.append(condition)
249257

250258
cdef void _register_decorator_components(self):
@@ -537,6 +545,13 @@ cdef class InputFilter:
537545
copy (Optional[str]): The name of the field to copy the value
538546
from.
539547
"""
548+
warnings.warn(
549+
"Using 'add' is deprecated, use 'field()' "
550+
"instead. https://leandercs.github.io/flask-inputfilter"
551+
"/options/declarative_api.html",
552+
DeprecationWarning,
553+
stacklevel=2,
554+
)
540555
if name in self.fields:
541556
raise ValueError(f"Field '{name}' already exists.")
542557

@@ -683,6 +698,13 @@ cdef class InputFilter:
683698
Args:
684699
filter: The filter to add.
685700
"""
701+
warnings.warn(
702+
"Using 'add_global_filter' is deprecated, use 'global_filter()' "
703+
"instead. https://leandercs.github.io/flask-inputfilter"
704+
"/options/declarative_api.html",
705+
DeprecationWarning,
706+
stacklevel=2,
707+
)
686708
self.global_filters.append(filter)
687709

688710
cpdef list[BaseFilter] get_global_filters(self):
@@ -784,6 +806,13 @@ cdef class InputFilter:
784806
Args:
785807
validator (BaseValidator): The validator to add.
786808
"""
809+
warnings.warn(
810+
"Using 'add_global_validator' is deprecated, use 'global_validator()' "
811+
"instead. https://leandercs.github.io/flask-inputfilter"
812+
"/options/declarative_api.html",
813+
DeprecationWarning,
814+
stacklevel=2,
815+
)
787816
self.global_validators.append(validator)
788817

789818
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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import logging
77
import sys
88
from typing import TYPE_CHECKING, Any, Optional, Type, TypeVar, Union
9+
import warnings
910

1011
from flask import Response, g, request
1112

@@ -211,6 +212,13 @@ def add_condition(self, condition: BaseCondition) -> None:
211212
Args:
212213
condition (BaseCondition): The condition to add.
213214
"""
215+
warnings.warn(
216+
"Using 'add_condition' is deprecated, use 'condition()' "
217+
"instead. https://leandercs.github.io/flask-inputfilter"
218+
"/options/declarative_api.html",
219+
DeprecationWarning,
220+
stacklevel=2,
221+
)
214222
self.conditions.append(condition)
215223

216224
def _register_decorator_components(self) -> None:
@@ -497,6 +505,13 @@ def add(
497505
copy (Optional[str]): The name of the field to copy the value
498506
from.
499507
"""
508+
warnings.warn(
509+
"Using 'add' is deprecated, use 'field()' "
510+
"instead. https://leandercs.github.io/flask-inputfilter"
511+
"/options/declarative_api.html",
512+
DeprecationWarning,
513+
stacklevel=2,
514+
)
500515
if name in self.fields:
501516
raise ValueError(f"Field '{name}' already exists.")
502517

@@ -643,6 +658,13 @@ def add_global_filter(self, filter: BaseFilter) -> None:
643658
Args:
644659
filter: The filter to add.
645660
"""
661+
warnings.warn(
662+
"Using 'add_global_filter' is deprecated, use 'global_filter()' "
663+
"instead. https://leandercs.github.io/flask-inputfilter"
664+
"/options/declarative_api.html",
665+
DeprecationWarning,
666+
stacklevel=2,
667+
)
646668
self.global_filters.append(filter)
647669

648670
def get_global_filters(self) -> list[BaseFilter]:
@@ -745,6 +767,13 @@ def add_global_validator(self, validator: BaseValidator) -> None:
745767
Args:
746768
validator (BaseValidator): The validator to add.
747769
"""
770+
warnings.warn(
771+
"Using 'add_global_validator' is deprecated, use 'global_validator()' "
772+
"instead. https://leandercs.github.io/flask-inputfilter"
773+
"/options/declarative_api.html",
774+
DeprecationWarning,
775+
stacklevel=2,
776+
)
748777
self.global_validators.append(validator)
749778

750779
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)