Skip to content

Commit

Permalink
✨ Run Ruff for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
yezz123 committed Dec 12, 2023
1 parent 834d512 commit 90f6c93
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
4 changes: 1 addition & 3 deletions pyngo/querydict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 3 additions & 9 deletions tests/errors_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'!"]}}}
8 changes: 2 additions & 6 deletions tests/querydict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 90f6c93

Please sign in to comment.