From 90f6c938e28bdf8edcc27bb65a2de6e8802a9a85 Mon Sep 17 00:00:00 2001 From: Yasser Tahiri Date: Tue, 12 Dec 2023 23:20:30 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Run=20Ruff=20for=20linting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyngo/querydict.py | 4 +--- tests/errors_test.py | 12 +++--------- tests/querydict_test.py | 8 ++------ 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/pyngo/querydict.py b/pyngo/querydict.py index f4429e7..9c66ab9 100644 --- a/pyngo/querydict.py +++ b/pyngo/querydict.py @@ -70,9 +70,7 @@ def querydict_to_dict( continue field = model_fields[field_key] # Discard field if its value is empty string and we don't expect string in model - if orig_value in ("", b"") and not issubclass( - field.outer_type_, (str, bytes, bytearray) - ): + if orig_value in ("", b"") and not issubclass(field.outer_type_, (str, bytes, bytearray)): continue if _is_sequence_field(field): to_dict[key] = query_dict.getlist(key) diff --git a/tests/errors_test.py b/tests/errors_test.py index b465dae..2ccc42c 100644 --- a/tests/errors_test.py +++ b/tests/errors_test.py @@ -42,16 +42,10 @@ def test_with_nested_field(self) -> None: try: MyModel.parse_obj({"int_field": 42, "nested_field": {"str_field": "foo"}}) except ValidationError as e: - assert drf_error_details(e) == { - "nested_field": {"str_field": ["Name must be: 'bar'!"]} - } + assert drf_error_details(e) == {"nested_field": {"str_field": ["Name must be: 'bar'!"]}} def test_with_nested_list(self) -> None: try: - MyModel.parse_obj( - {"nested_list": [{"str_field": "bar"}, {"str_field": "foo"}]} - ) + MyModel.parse_obj({"nested_list": [{"str_field": "bar"}, {"str_field": "foo"}]}) except ValidationError as e: - assert drf_error_details(e) == { - "nested_list": {"1": {"str_field": ["Name must be: 'bar'!"]}} - } + assert drf_error_details(e) == {"nested_list": {"1": {"str_field": ["Name must be: 'bar'!"]}}} diff --git a/tests/querydict_test.py b/tests/querydict_test.py index f7e5359..3eda473 100644 --- a/tests/querydict_test.py +++ b/tests/querydict_test.py @@ -27,9 +27,7 @@ class Model(QueryDictModel, BaseModel): ( ( QueryDict("foo=12&bar=12"), - Model( - foo=12, bar=[12], key="key", wings=(), queue=deque(), basket=frozenset() - ), + Model(foo=12, bar=[12], key="key", wings=(), queue=deque(), basket=frozenset()), ), ({"foo": 44, "bar": [0, 4]}, Model(foo=44, bar=[0, 4], key="key")), ( @@ -63,9 +61,7 @@ class Model(QueryDictModel, BaseModel): ), ), ) -def test_parsing_objects( - data: Union[QueryDict, Dict[str, Any]], expected: Model -) -> None: +def test_parsing_objects(data: Union[QueryDict, Dict[str, Any]], expected: Model) -> None: got = Model.parse_obj(data) assert got == expected assert got.foo == expected.foo