Skip to content

Commit 21cc21d

Browse files
illusionalgtmanfred
authored andcommitted
Black formatting
1 parent 08385bf commit 21cc21d

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

flask_rebar/compat.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ def exclude_unknown_fields(schema: Schema) -> Schema:
7272

7373

7474
# Marshmallow version detection for backward compatibility
75-
MARSHMALLOW_VERSION_MAJOR = int(version('marshmallow').split('.')[0])
75+
MARSHMALLOW_VERSION_MAJOR = int(version("marshmallow").split(".")[0])
76+
7677

7778
def is_schema_ordered(schema: Schema) -> bool:
7879
"""
7980
Check if a schema should maintain field order.
80-
81+
8182
In Marshmallow 3.x, this is controlled by the 'ordered' attribute.
8283
In Marshmallow 4.x+, field order is always preserved (insertion order from dict).
83-
84+
8485
:param Schema schema: The schema to check
8586
:return: True if fields should maintain their order, False if they should be sorted
8687
:rtype: bool
@@ -90,4 +91,4 @@ def is_schema_ordered(schema: Schema) -> bool:
9091
return True
9192
else:
9293
# In Marshmallow 3, check the 'ordered' attribute
93-
return getattr(schema, 'ordered', False)
94+
return getattr(schema, "ordered", False)

flask_rebar/swagger_generation/marshmallow_to_swagger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def get_schema_fields(schema: Schema) -> List[Tuple[str, m.fields.Field]]:
182182
for name, field in schema.fields.items():
183183
prop = compat.get_data_key(field)
184184
fields.append((prop, field))
185-
185+
186186
# In Marshmallow 3.x, respect the 'ordered' Meta option for field ordering.
187187
# When ordered=False (default), fields should be sorted alphabetically.
188188
# In Marshmallow 4.0+, field order is always preserved (insertion order).

tests/swagger_generation/test_marshmallow_to_swagger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ class Foo(m.Schema):
426426

427427
@pytest.mark.skipif(
428428
MARSHMALLOW_VERSION_MAJOR >= 4,
429-
reason="'self' nested reference removed in marshmallow 4.x"
429+
reason="'self' nested reference removed in marshmallow 4.x",
430430
)
431431
def test_self_referential_nested_pre_3_3(self):
432432
# Issue 90

tests/test_rebar.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
# Make it optional for tests
2121
try:
2222
import marshmallow_objects as mo
23+
2324
# Test that marshmallow-objects actually works with current marshmallow version
2425
# by trying to create a simple model - it fails with marshmallow 4.x
2526
class _TestModel(mo.Model):
2627
test = mo.fields.String()
28+
2729
_TestModel() # This will fail if incompatible
2830
MARSHMALLOW_OBJECTS_AVAILABLE = True
2931
del _TestModel
@@ -73,6 +75,7 @@ class HeadersSchema(m.Schema):
7375

7476
# marshmallow-objects Model classes (only defined if library is available)
7577
if MARSHMALLOW_OBJECTS_AVAILABLE:
78+
7679
class FooModel(mo.Model):
7780
uid = mo.fields.String()
7881
name = mo.fields.String()
@@ -88,6 +91,7 @@ class FooListModel(mo.Model):
8891

8992
class HeadersModel(mo.Model):
9093
name = set_data_key(field=mo.fields.String(required=True), key="x-name")
94+
9195
else:
9296
# Placeholders when marshmallow-objects is not available
9397
FooModel = None # type: ignore
@@ -385,9 +389,7 @@ def list_foos():
385389
resp = app.test_client().get(path="/foos?foo=bar") # missing required parameter
386390
self.assertEqual(resp.status_code, 400)
387391

388-
@parametrize(
389-
"headers_cls, use_model", _headers_cls_test_cases
390-
)
392+
@parametrize("headers_cls, use_model", _headers_cls_test_cases)
391393
def test_validate_headers(self, headers_cls, use_model):
392394
rebar = Rebar()
393395
registry = rebar.create_handler_registry()
@@ -668,9 +670,7 @@ def handler_func(foo_uid):
668670
self.assertIn("get", swagger["paths"]["/foos/{foo_uid}"])
669671
self.assertIn("patch", swagger["paths"]["/foos/{foo_uid}"])
670672

671-
@parametrize(
672-
"headers_def, use_model", _headers_def_test_cases
673-
)
673+
@parametrize("headers_def, use_model", _headers_def_test_cases)
674674
def test_default_headers(self, headers_def, use_model):
675675
rebar = Rebar()
676676
registry = rebar.create_handler_registry()

tests/test_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_validation_works(self):
101101
error_msg = str(ctx.exception.messages)
102102
self.assertTrue(
103103
"isoformat" in error_msg,
104-
f"Expected 'isoformat' error message, got: {error_msg}"
104+
f"Expected 'isoformat' error message, got: {error_msg}",
105105
)
106106

107107
def test_required_failed_validate(self):

0 commit comments

Comments
 (0)