Skip to content

Commit

Permalink
really drop python<=3.7 support (#1232)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
  • Loading branch information
kloczek and davidhewitt authored Mar 19, 2024
1 parent abff9ba commit 092f5f0
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tests/benchmarks/complete_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ def input_data_lax():
'field_frozenset_bytes': frozenset([f'{i}'.encode() for i in range(100)]),
'field_frozenset_bytes_con': frozenset([f'{i}'.encode() for i in range(42)]),
'field_tuple_var_len_any': ('a', b'b', True, 1.0, None),
'field_tuple_var_len_float': tuple((i + 0.5 for i in range(100))),
'field_tuple_var_len_float_con': tuple((i + 0.5 for i in range(42))),
'field_tuple_var_len_float': tuple(i + 0.5 for i in range(100)),
'field_tuple_var_len_float_con': tuple(i + 0.5 for i in range(42)),
'field_tuple_fix_len': ('a', 1, 1.0, True),
'field_dict_any': {'a': 'b', 1: True, 1.0: 1.0},
'field_dict_str_float': {f'{i}': i + 0.5 for i in range(100)},
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/test_complete_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def test_complete_valid():
'field_frozenset_bytes': frozenset([f'{i}'.encode() for i in range(100)]),
'field_frozenset_bytes_con': frozenset([f'{i}'.encode() for i in range(42)]),
'field_tuple_var_len_any': ('a', b'b', True, 1.0, None),
'field_tuple_var_len_float': tuple((i + 0.5 for i in range(100))),
'field_tuple_var_len_float_con': tuple((i + 0.5 for i in range(42))),
'field_tuple_var_len_float': tuple(i + 0.5 for i in range(100)),
'field_tuple_var_len_float_con': tuple(i + 0.5 for i in range(42)),
'field_tuple_fix_len': ('a', 1, 1.0, True),
'field_dict_any': {'a': 'b', 1: True, 1.0: 1.0},
'field_dict_str_float': {f'{i}': i + 0.5 for i in range(100)},
Expand Down
6 changes: 2 additions & 4 deletions tests/serializers/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@


def gen_ok(*things):
for thing in things:
yield thing
yield from things


def gen_error(*things):
for thing in things:
yield thing
yield from things
raise ValueError('oops')


Expand Down
6 changes: 3 additions & 3 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def test_error_type(error_type, message, context):


def test_all_errors_covered():
listed_types = set(error_type for error_type, *_ in all_errors)
listed_types = {error_type for error_type, *_ in all_errors}
actual_types = {e['type'] for e in list_all_errors()}
assert actual_types == listed_types

Expand Down Expand Up @@ -464,7 +464,7 @@ def test_custom_context_for_simple_error():
def test_all_errors():
errors = list_all_errors()
# print(f'{len(errors)=}')
assert len(errors) == len(set(e['type'] for e in errors)), 'error types are not unique'
assert len(errors) == len({e['type'] for e in errors}), 'error types are not unique'
# insert_assert(errors[:4])
assert errors[:4] == [
{
Expand Down Expand Up @@ -689,7 +689,7 @@ def singular_raise_py_error(v: Any) -> Any:
s.validate_python('anything')
assert exc_info.value.__cause__ is None
else:
raise AssertionError('Unhandled result: {}'.format(expected_result))
raise AssertionError(f'Unhandled result: {expected_result}')


def test_validation_error_cause_traceback_preserved():
Expand Down
4 changes: 2 additions & 2 deletions tests/validators/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
from datetime import date, datetime, time, timedelta, timezone
from decimal import Decimal
from typing import Any, Dict
from typing import Any

import pytest

Expand Down Expand Up @@ -199,7 +199,7 @@ def test_date_strict_json_ctx():
({'gt': date(2000, 1, 1)}, '2000-01-01', Err('Input should be greater than 2000-01-01 [type=greater_than,')),
],
)
def test_date_kwargs(kwargs: Dict[str, Any], input_value: date, expected: Err | date):
def test_date_kwargs(kwargs: dict[str, Any], input_value: date, expected: Err | date):
v = SchemaValidator({'type': 'date', **kwargs}) # type: ignore
if isinstance(expected, Err):
with pytest.raises(ValidationError, match=re.escape(expected.message)):
Expand Down
4 changes: 2 additions & 2 deletions tests/validators/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import math
import re
from decimal import Decimal
from typing import Any, Dict
from typing import Any

import pytest
from dirty_equals import FunctionCheck, IsStr
Expand Down Expand Up @@ -157,7 +157,7 @@ def test_decimal_strict_json(input_value, expected):
({'lt': 0.123456}, 1, Err('Input should be less than 0.123456')),
],
)
def test_decimal_kwargs(py_and_json: PyAndJson, kwargs: Dict[str, Any], input_value, expected):
def test_decimal_kwargs(py_and_json: PyAndJson, kwargs: dict[str, Any], input_value, expected):
v = py_and_json({'type': 'decimal', **kwargs})
if isinstance(expected, Err):
with pytest.raises(ValidationError, match=re.escape(expected.message)):
Expand Down
2 changes: 1 addition & 1 deletion tests/validators/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class ListInputTestCase:
LAX_MODE_INPUTS: List[Any] = [
(1, 2, 3),
frozenset((1, 2, 3)),
set((1, 2, 3)),
{1, 2, 3},
deque([1, 2, 3]),
{1: 'a', 2: 'b', 3: 'c'}.keys(),
{'a': 1, 'b': 2, 'c': 3}.values(),
Expand Down
2 changes: 1 addition & 1 deletion tests/validators/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_tuple_validate(input_value, expected, variadic_item_index, items):
)
def test_tuple_validate_iterator(variadic_item_index, items):
v = SchemaValidator(core_schema.tuple_schema(items_schema=items, variadic_item_index=variadic_item_index))
assert v.validate_python((x for x in [1, 2, '3'])) == (1, 2, 3)
assert v.validate_python(x for x in [1, 2, '3']) == (1, 2, 3)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 092f5f0

Please sign in to comment.