Skip to content

Commit e0c77a6

Browse files
committed
48 | Fix flake8
1 parent 683a3e1 commit e0c77a6

File tree

97 files changed

+566
-555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+566
-555
lines changed

flask_inputfilter/conditions/array_length_equal_condition.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ class ArrayLengthEqualCondition(BaseCondition):
1616
1717
**Expected Behavior:**
1818
19-
Validates that the length of the array from ``first_array_field`` is equal to the length of the array from ``second_array_field``. If not, the condition fails.
19+
Validates that the length of the array from ``first_array_field`` is
20+
equal to the length of the array from ``second_array_field``. If not,
21+
the condition fails.
2022
2123
**Example Usage:**
2224
2325
.. code-block:: python
2426
25-
from flask_inputfilter import InputFilter
26-
from flask_inputfilter.conditions import ArrayLengthEqualCondition
27-
from flask_inputfilter.validators import IsArrayValidator
28-
2927
class ArrayLengthFilter(InputFilter):
3028
def __init__(self):
3129
super().__init__()
@@ -40,7 +38,12 @@ def __init__(self):
4038
validators=[IsArrayValidator()]
4139
)
4240
43-
self.add_condition(ArrayLengthEqualCondition('list1', 'list2'))
41+
self.add_condition(
42+
ArrayLengthEqualCondition(
43+
first_array_field='list1',
44+
second_array_field='list2'
45+
)
46+
)
4447
"""
4548

4649
__slots__ = ("first_array_field", "second_array_field")

flask_inputfilter/conditions/array_longer_than_condition.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
class ArrayLongerThanCondition(BaseCondition):
99
"""
10-
Checks if the array in one field is longer than the array in
11-
another field.
10+
Checks if the array in one field is longer than the array in another field.
1211
1312
**Parameters:**
1413
@@ -17,16 +16,13 @@ class ArrayLongerThanCondition(BaseCondition):
1716
1817
**Expected Behavior:**
1918
20-
Validates that the array in ``longer_field`` has more elements than the array in ``shorter_field``.
19+
Validates that the array in ``longer_field`` has more elements than
20+
the array in ``shorter_field``.
2121
2222
**Example Usage:**
2323
2424
.. code-block:: python
2525
26-
from flask_inputfilter import InputFilter
27-
from flask_inputfilter.conditions import ArrayLongerThanCondition
28-
from flask_inputfilter.validators import IsArrayValidator
29-
3026
class ArrayComparisonFilter(InputFilter):
3127
def __init__(self):
3228
super().__init__()
@@ -41,7 +37,12 @@ def __init__(self):
4137
validators=[IsArrayValidator()]
4238
)
4339
44-
self.add_condition(ArrayLongerThanCondition('list1', 'list2'))
40+
self.add_condition(
41+
ArrayLongerThanCondition(
42+
longer_field='list1',
43+
shorter_field='list2'
44+
)
45+
)
4546
"""
4647

4748
__slots__ = ("longer_field", "shorter_field")

flask_inputfilter/conditions/custom_condition.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@
88

99
class CustomCondition(BaseCondition):
1010
"""
11-
Allows defining a custom condition using a user-provided
12-
callable.
11+
Allows defining a custom condition using a user-provided callable.
1312
1413
**Parameters:**
1514
16-
- **condition** (*Callable[[Dict[str, Any]], bool]*): A function that takes the input data and returns a boolean indicating whether the condition is met.
15+
- **condition** (*Callable[[Dict[str, Any]], bool]*): A function that
16+
takes the input data and returns a boolean indicating whether the
17+
condition is met.
1718
1819
**Expected Behavior:**
1920
20-
Executes the provided callable with the input data. The condition passes if the callable returns ``True``, and fails otherwise.
21+
Executes the provided callable with the input data. The condition passes
22+
if the callable returns ``True``, and fails otherwise.
2123
2224
**Example Usage:**
2325
2426
.. code-block:: python
2527
26-
from flask_inputfilter import InputFilter
27-
from flask_inputfilter.conditions import CustomCondition
28-
from flask_inputfilter.validators import IsIntegerValidator
29-
3028
def my_custom_condition(data):
3129
return data.get('age', 0) >= 18
3230
@@ -39,7 +37,11 @@ def __init__(self):
3937
validators=[IsIntegerValidator()]
4038
)
4139
42-
self.add_condition(CustomCondition(my_custom_condition))
40+
self.add_condition(
41+
CustomCondition(
42+
condition=my_custom_condition
43+
)
44+
)
4345
"""
4446

4547
__slots__ = ("condition",)

flask_inputfilter/conditions/equal_condition.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ class EqualCondition(BaseCondition):
1616
1717
**Expected Behavior:**
1818
19-
Validates that the values of ``first_field`` and ``second_field`` are equal. Fails if they differ.
19+
Validates that the values of ``first_field`` and ``second_field`` are
20+
equal. Fails if they differ.
2021
2122
**Example Usage:**
2223
2324
.. code-block:: python
2425
25-
from flask_inputfilter import InputFilter
26-
from flask_inputfilter.conditions import EqualCondition
27-
2826
class EqualFieldsFilter(InputFilter):
2927
def __init__(self):
3028
super().__init__()
@@ -37,7 +35,12 @@ def __init__(self):
3735
'confirm_password'
3836
)
3937
40-
self.add_condition(EqualCondition('password', 'confirm_password'))
38+
self.add_condition(
39+
EqualCondition(
40+
first_field='password',
41+
second_field='confirm_password'
42+
)
43+
)
4144
"""
4245

4346
__slots__ = ("first_field", "second_field")

flask_inputfilter/conditions/exactly_n_of_condition.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
class ExactlyNOfCondition(BaseCondition):
99
"""
10-
Checks that exactly ``n`` of the specified fields are present in
11-
the input data.
10+
Checks that exactly ``n`` of the specified fields are present in the input
11+
data.
1212
1313
**Parameters:**
1414
@@ -17,15 +17,13 @@ class ExactlyNOfCondition(BaseCondition):
1717
1818
**Expected Behavior:**
1919
20-
Counts the number of specified fields present in the data and validates that the count equals ``n``.
20+
Counts the number of specified fields present in the data and
21+
validates that the count equals ``n``.
2122
2223
**Example Usage:**
2324
2425
.. code-block:: python
2526
26-
from flask_inputfilter import InputFilter
27-
from flask_inputfilter.conditions import ExactlyNOfCondition
28-
2927
class ExactFieldsFilter(InputFilter):
3028
def __init__(self):
3129
super().__init__()
@@ -42,7 +40,12 @@ def __init__(self):
4240
'field3'
4341
)
4442
45-
self.add_condition(ExactlyNOfCondition(['field1', 'field2', 'field3'], 2))
43+
self.add_condition(
44+
ExactlyNOfCondition(
45+
fields=['field1', 'field2', 'field3'],
46+
n=2
47+
)
48+
)
4649
"""
4750

4851
__slots__ = ("fields", "n")

flask_inputfilter/conditions/exactly_n_of_matches_condition.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
class ExactlyNOfMatchesCondition(BaseCondition):
99
"""
10-
Checks that exactly ``n`` of the specified fields match a given
11-
value.
10+
Checks that exactly ``n`` of the specified fields match a given value.
1211
1312
**Parameters:**
1413
@@ -18,15 +17,13 @@ class ExactlyNOfMatchesCondition(BaseCondition):
1817
1918
**Expected Behavior:**
2019
21-
Validates that exactly ``n`` fields among the specified ones have the given value.
20+
Validates that exactly ``n`` fields among the specified ones have the
21+
given value.
2222
2323
**Example Usage:**
2424
2525
.. code-block:: python
2626
27-
from flask_inputfilter import InputFilter
28-
from flask_inputfilter.conditions import ExactlyNOfMatchesCondition
29-
3027
class MatchFieldsFilter(InputFilter):
3128
def __init__(self):
3229
super().__init__()
@@ -39,7 +36,13 @@ def __init__(self):
3936
'field2'
4037
)
4138
42-
self.add_condition(ExactlyNOfMatchesCondition(['field1', 'field2'], 1, 'expected_value'))
39+
self.add_condition(
40+
ExactlyNOfMatchesCondition(
41+
fields=['field1', 'field2'],
42+
n=1,
43+
value='expected_value'
44+
)
45+
)
4346
"""
4447

4548
__slots__ = ("fields", "n", "value")

flask_inputfilter/conditions/exactly_one_of_condition.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ class ExactlyOneOfCondition(BaseCondition):
1515
1616
**Expected Behavior:**
1717
18-
Validates that only one field among the specified fields exists in the input data.
18+
Validates that only one field among the specified fields exists in the
19+
input data.
1920
2021
**Example Usage:**
2122
2223
.. code-block:: python
2324
24-
from flask_inputfilter import InputFilter
25-
from flask_inputfilter.conditions import ExactlyOneOfCondition
26-
2725
class OneFieldFilter(InputFilter):
2826
def __init__(self):
2927
super().__init__()

flask_inputfilter/conditions/exactly_one_of_matches_condition.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
class ExactlyOneOfMatchesCondition(BaseCondition):
99
"""
10-
Ensures that exactly one of the specified fields matches a given
11-
value.
10+
Ensures that exactly one of the specified fields matches a given value.
1211
1312
**Parameters:**
1413
@@ -23,9 +22,6 @@ class ExactlyOneOfMatchesCondition(BaseCondition):
2322
2423
.. code-block:: python
2524
26-
from flask_inputfilter import InputFilter
27-
from flask_inputfilter.conditions import ExactlyOneOfMatchesCondition
28-
2925
class OneMatchFilter(InputFilter):
3026
def __init__(self):
3127
super().__init__()
@@ -38,7 +34,12 @@ def __init__(self):
3834
'option2'
3935
)
4036
41-
self.add_condition(ExactlyOneOfMatchesCondition(['option1', 'option2'], 'yes'))
37+
self.add_condition(
38+
ExactlyOneOfMatchesCondition(
39+
fields=['option1', 'option2'],
40+
value='yes'
41+
)
42+
)
4243
"""
4344

4445
__slots__ = ("fields", "value")

flask_inputfilter/conditions/integer_bigger_than_condition.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
class IntegerBiggerThanCondition(BaseCondition):
99
"""
10-
Checks if the integer value in one field is greater than that in
11-
another field.
10+
Checks if the integer value in one field is greater than that in another
11+
field.
1212
1313
**Parameters:**
1414
@@ -17,16 +17,13 @@ class IntegerBiggerThanCondition(BaseCondition):
1717
1818
**Expected Behavior:**
1919
20-
Validates that the integer value from ``bigger_field`` is greater than the value from ``smaller_field``.
20+
Validates that the integer value from ``bigger_field`` is greater than
21+
the value from ``smaller_field``.
2122
2223
**Example Usage:**
2324
2425
.. code-block:: python
2526
26-
from flask_inputfilter import InputFilter
27-
from flask_inputfilter.conditions import IntegerBiggerThanCondition
28-
from flask_inputfilter.validators import IsIntegerValidator
29-
3027
class NumberComparisonFilter(InputFilter):
3128
def __init__(self):
3229
super().__init__()
@@ -41,7 +38,12 @@ def __init__(self):
4138
validators=[IsIntegerValidator()]
4239
)
4340
44-
self.add_condition(IntegerBiggerThanCondition('field_should_be_bigger', 'field_should_be_smaller'))
41+
self.add_condition(
42+
IntegerBiggerThanCondition(
43+
bigger_field='field_should_be_bigger',
44+
smaller_field='field_should_be_smaller'
45+
)
46+
)
4547
"""
4648

4749
__slots__ = ("bigger_field", "smaller_field")

flask_inputfilter/conditions/n_of_condition.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
class NOfCondition(BaseCondition):
99
"""
10-
Checks that at least ``n`` of the specified fields are present in
11-
the input data.
10+
Checks that at least ``n`` of the specified fields are present in the input
11+
data.
1212
1313
**Parameters:**
1414
@@ -17,15 +17,13 @@ class NOfCondition(BaseCondition):
1717
1818
**Expected Behavior:**
1919
20-
Validates that the count of the specified fields present is greater than or equal to ``n``.
20+
Validates that the count of the specified fields present is greater
21+
than or equal to ``n``.
2122
2223
**Example Usage:**
2324
2425
.. code-block:: python
2526
26-
from flask_inputfilter import InputFilter
27-
from flask_inputfilter.conditions import NOfCondition
28-
2927
class MinimumFieldsFilter(InputFilter):
3028
def __init__(self):
3129
super().__init__()
@@ -42,7 +40,12 @@ def __init__(self):
4240
'field3'
4341
)
4442
45-
self.add_condition(NOfCondition(['field1', 'field2', 'field3'], 2))
43+
self.add_condition(
44+
NOfCondition(
45+
fields=['field1', 'field2', 'field3'],
46+
n=2
47+
)
48+
)
4649
"""
4750

4851
__slots__ = ("fields", "n")

0 commit comments

Comments
 (0)