Skip to content

Commit 22a5c01

Browse files
committed
black formatted
1 parent b9dd047 commit 22a5c01

File tree

6 files changed

+28
-59
lines changed

6 files changed

+28
-59
lines changed

src/masoniteorm/commands/MigrateStatusCommand.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,20 @@ def handle(self):
3030
batch = migration_data["batch"]
3131

3232
migrations.append(
33-
["<info>Y</info>", f"<comment>{migration_file}</comment>", f"<info>{batch}</info>"]
33+
[
34+
"<info>Y</info>",
35+
f"<comment>{migration_file}</comment>",
36+
f"<info>{batch}</info>",
37+
]
3438
)
3539

3640
for migration_file in migration.get_unran_migrations():
3741
migrations.append(
38-
["<error>N</error>", f"<comment>{migration_file}</comment>", "<info>-</info>"]
42+
[
43+
"<error>N</error>",
44+
f"<comment>{migration_file}</comment>",
45+
"<info>-</info>",
46+
]
3947
)
4048

4149
table.set_rows(migrations)

src/masoniteorm/query/QueryBuilder.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
HTTP404,
1010
ConnectionNotRegistered,
1111
ModelNotFound,
12-
MultipleRecordsFound, InvalidArgument,
12+
MultipleRecordsFound,
13+
InvalidArgument,
1314
)
1415
from ..expressions.expressions import (
1516
AggregateExpression,
@@ -47,7 +48,7 @@ def __init__(
4748
scopes=None,
4849
schema=None,
4950
dry=False,
50-
config_path=None
51+
config_path=None,
5152
):
5253
"""QueryBuilder initializer
5354

src/masoniteorm/schema/Schema.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(
5757
grammar=None,
5858
connection_details=None,
5959
schema=None,
60-
config_path=None
60+
config_path=None,
6161
):
6262
self._dry = dry
6363
self.connection = connection
@@ -306,11 +306,7 @@ def get_all_tables(self):
306306

307307
result = self.new_connection().query(sql, ())
308308

309-
return (
310-
list(map(lambda t: list(t.values())[0], result))
311-
if result
312-
else []
313-
)
309+
return list(map(lambda t: list(t.values())[0], result)) if result else []
314310

315311
def has_table(self, table, query_only=False):
316312
"""Checks if the a database has a specific table

tests/models/test_models.py

+6-21
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,17 @@ class ModelTest(Model):
1919

2020

2121
class FillableModelTest(Model):
22-
__fillable__ = [
23-
"due_date",
24-
"is_vip",
25-
]
22+
__fillable__ = ["due_date", "is_vip"]
2623

2724

2825
class InvalidFillableGuardedModelTest(Model):
29-
__fillable__ = [
30-
"due_date",
31-
]
32-
__guarded__ = [
33-
"is_vip",
34-
"payload",
35-
]
26+
__fillable__ = ["due_date"]
27+
__guarded__ = ["is_vip", "payload"]
3628

3729

3830
class InvalidFillableGuardedChildModelTest(ModelTest):
39-
__fillable__ = [
40-
"due_date",
41-
]
42-
__guarded__ = [
43-
"is_vip",
44-
"payload",
45-
]
31+
__fillable__ = ["due_date"]
32+
__guarded__ = ["is_vip", "payload"]
4633

4734

4835
class ModelTestForced(Model):
@@ -147,9 +134,7 @@ def test_model_can_cast_dict_attributes(self):
147134

148135
def test_valid_json_cast(self):
149136
model = ModelTest.hydrate(
150-
{
151-
"payload": {"this": "dict", "is": "usable", "as": "json"},
152-
}
137+
{"payload": {"this": "dict", "is": "usable", "as": "json"}}
153138
)
154139

155140
self.assertEqual(type(model.payload), dict)

tests/mysql/model/test_model.py

+5-22
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ def test_create_can_use_guarded_asterisk(self):
113113

114114
# An asterisk guarded attribute excludes all fields from mass-assignment.
115115
# This would raise a DB error if there are any required fields.
116-
self.assertEqual(
117-
sql,
118-
"INSERT INTO `profiles` (*) VALUES ()",
119-
)
116+
self.assertEqual(sql, "INSERT INTO `profiles` (*) VALUES ()")
120117

121118
def test_bulk_create_can_use_fillable(self):
122119
query_builder = ProfileFillable.bulk_create(
@@ -173,8 +170,7 @@ def test_bulk_create_can_use_guarded_asterisk(self):
173170
# This would obviously raise an invalid SQL syntax error.
174171
# TODO: Raise a clearer error?
175172
self.assertEqual(
176-
query_builder.to_sql(),
177-
"INSERT INTO `profiles` () VALUES (), ()",
173+
query_builder.to_sql(), "INSERT INTO `profiles` () VALUES (), ()"
178174
)
179175

180176
def test_update_can_use_fillable(self):
@@ -214,10 +210,7 @@ def test_update_can_use_guarded_asterisk(self):
214210

215211
# An asterisk guarded attribute excludes all fields from mass-assignment.
216212
# The query builder's sql should not have been altered in any way.
217-
self.assertEqual(
218-
query_builder.to_sql(),
219-
initial_sql,
220-
)
213+
self.assertEqual(query_builder.to_sql(), initial_sql)
221214

222215
def test_table_name(self):
223216
table_name = Profile.get_table_name()
@@ -250,25 +243,15 @@ def test_serialize_with_hidden(self):
250243

251244
def test_serialize_with_visible(self):
252245
profile = ProfileSerializeWithVisible.hydrate(
253-
{
254-
"name": "Joe",
255-
"id": 1,
256-
"password": "secret",
257-
"email": "[email protected]",
258-
}
246+
{"name": "Joe", "id": 1, "password": "secret", "email": "[email protected]"}
259247
)
260248
self.assertTrue(
261249
{"name": "Joe", "email": "[email protected]"}, profile.serialize()
262250
)
263251

264252
def test_serialize_with_visible_and_hidden_raise_error(self):
265253
profile = ProfileSerializeWithVisibleAndHidden.hydrate(
266-
{
267-
"name": "Joe",
268-
"id": 1,
269-
"password": "secret",
270-
"email": "[email protected]",
271-
}
254+
{"name": "Joe", "id": 1, "password": "secret", "email": "[email protected]"}
272255
)
273256
with self.assertRaises(AttributeError):
274257
profile.serialize()

tests/sqlite/models/test_sqlite_model.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,13 @@ def test_find_or_if_record_not_found(self):
8787
record_id = 1_000_000_000_000_000
8888

8989
result = User.find_or(record_id, lambda: "Record not found.")
90-
self.assertEqual(
91-
result, "Record not found."
92-
)
90+
self.assertEqual(result, "Record not found.")
9391

9492
def test_find_or_if_record_found(self):
9593
record_id = 1
9694
result_id = User.find_or(record_id, lambda: "Record not found.").id
9795

98-
self.assertEqual(
99-
result_id, record_id
100-
)
96+
self.assertEqual(result_id, record_id)
10197

10298
def test_can_set_and_retreive_attribute(self):
10399
user = User.hydrate({"id": 1, "name": "joe", "customer_id": 1})

0 commit comments

Comments
 (0)