Skip to content

Commit 390add1

Browse files
authored
chore: add black code formatter to the project (#179)
This commit adds the [Black](https://github.com/psf/black) code formatter to the project and updates the `Makefile` to use it. There are 2 targets that run the `black` tool: - `make lint`: this will check the code with both `pylint` and `black` - `make lint-fix`: this will reformat the code using `black`. It also re-formats the Python files by running `make lint-fix`. Signed-off-by: Norbert Biczo <[email protected]>
1 parent 3e64860 commit 390add1

File tree

85 files changed

+10059
-15731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+10059
-15731
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ test-examples:
3232
python -m pytest examples
3333

3434
lint:
35-
./pylint.sh
35+
./pylint.sh && black --check .
36+
37+
lint-fix:
38+
black .

examples/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
"""Examples"""
44

5-
# this file is present so that pylint will lint-check the files in this directory
5+
# this file is present so that pylint will lint-check the files in this directory

examples/test_case_management_v1_examples.py

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
# Start of Examples for Service: CaseManagementV1
5252
##############################################################################
5353
# region
54-
class TestCaseManagementV1Examples():
54+
class TestCaseManagementV1Examples:
5555
"""
5656
Example Test Class for CaseManagementV1
5757
"""
@@ -64,16 +64,14 @@ def setup_class(cls):
6464

6565
# begin-common
6666

67-
case_management_service = CaseManagementV1.new_instance(
68-
)
67+
case_management_service = CaseManagementV1.new_instance()
6968

7069
# end-common
7170
assert case_management_service is not None
7271

7372
# Load the configuration
7473
global config
75-
config = read_external_sources(
76-
CaseManagementV1.DEFAULT_SERVICE_NAME)
74+
config = read_external_sources(CaseManagementV1.DEFAULT_SERVICE_NAME)
7775

7876
global resource_crn
7977
resource_crn = config['RESOURCE_CRN']
@@ -93,14 +91,8 @@ def test_create_case_example(self):
9391
print('\ncreate_case() result:')
9492
# begin-createCase
9593

96-
offering_type = OfferingType(
97-
group='crn_service_name',
98-
key='cloud-object-storage'
99-
)
100-
offering_payload = Offering(
101-
name='Cloud Object Storage',
102-
type=offering_type
103-
)
94+
offering_type = OfferingType(group='crn_service_name', key='cloud-object-storage')
95+
offering_payload = Offering(name='Cloud Object Storage', type=offering_type)
10496

10597
case = case_management_service.create_case(
10698
type='technical',
@@ -141,10 +133,7 @@ def test_get_case_example(self):
141133
GetCaseEnums.Fields.CREATED_BY,
142134
]
143135

144-
case = case_management_service.get_case(
145-
case_number=case_number,
146-
fields=fields_to_return
147-
).get_result()
136+
case = case_management_service.get_case(case_number=case_number, fields=fields_to_return).get_result()
148137

149138
print(json.dumps(case, indent=2))
150139

@@ -187,8 +176,7 @@ def test_add_comment_example(self):
187176
# begin-addComment
188177

189178
comment = case_management_service.add_comment(
190-
case_number=case_number,
191-
comment='This is an example comment.'
179+
case_number=case_number, comment='This is an example comment.'
192180
).get_result()
193181

194182
print(json.dumps(comment, indent=2))
@@ -209,9 +197,7 @@ def test_add_watchlist_example(self):
209197
print('\nadd_watchlist() result:')
210198
# begin-addWatchlist
211199

212-
watchlist_users = [
213-
User(realm='IBMid', user_id='[email protected]')
214-
]
200+
watchlist_users = [User(realm='IBMid', user_id='[email protected]')]
215201

216202
watchlist_add_response = case_management_service.add_watchlist(
217203
case_number=case_number,
@@ -236,9 +222,7 @@ def test_remove_watchlist_example(self):
236222
print('\nremove_watchlist() result:')
237223
# begin-removeWatchlist
238224

239-
watchlist_users = [
240-
User(realm='IBMid', user_id='[email protected]')
241-
]
225+
watchlist_users = [User(realm='IBMid', user_id='[email protected]')]
242226

243227
watchlist = case_management_service.remove_watchlist(
244228
case_number=case_number,
@@ -355,8 +339,7 @@ def test_delete_file_example(self):
355339
# begin-deleteFile
356340

357341
attachment_list = case_management_service.delete_file(
358-
case_number=case_number,
359-
file_id=attachment_id
342+
case_number=case_number, file_id=attachment_id
360343
).get_result()
361344

362345
print(json.dumps(attachment_list, indent=2))
@@ -384,8 +367,7 @@ def test_update_case_status_example(self):
384367
}
385368

386369
case = case_management_service.update_case_status(
387-
case_number=case_number,
388-
status_payload=status_payload_model
370+
case_number=case_number, status_payload=status_payload_model
389371
).get_result()
390372

391373
print(json.dumps(case, indent=2))
@@ -395,6 +377,7 @@ def test_update_case_status_example(self):
395377
except ApiException as e:
396378
pytest.fail(str(e))
397379

380+
398381
# endregion
399382
##############################################################################
400383
# End of Examples for Service: CaseManagementV1

0 commit comments

Comments
 (0)