Skip to content

Commit 0908682

Browse files
author
Allie Crevier
committed
reformat with black
1 parent 3346e30 commit 0908682

File tree

16 files changed

+60
-120
lines changed

16 files changed

+60
-120
lines changed

securedrop_client/api_jobs/downloads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _get_realistic_timeout(self, size_in_bytes: int) -> int:
8383
8484
* Minimum timeout allowed is 25 seconds
8585
"""
86-
TIMEOUT_BYTES_PER_SECOND = 100000.0
86+
TIMEOUT_BYTES_PER_SECOND = 100_000.0
8787
TIMEOUT_ADJUSTMENT_FACTOR = 1.5
8888
TIMEOUT_BASE = 25
8989
timeout = math.ceil((size_in_bytes / TIMEOUT_BYTES_PER_SECOND) * TIMEOUT_ADJUSTMENT_FACTOR)

securedrop_client/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def from_home_dir(cls: Type[T], sdc_home: str) -> T:
2727
logger.error("Error opening config file at {}: {}".format(full_path, e))
2828
json_config = {}
2929

30-
return cls(journalist_key_fingerprint=json_config.get("journalist_key_fingerprint", None),)
30+
return cls(journalist_key_fingerprint=json_config.get("journalist_key_fingerprint", None))
3131

3232
@property
3333
def is_valid(self) -> bool:

securedrop_client/export.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ class Export(QObject):
5959
DISK_TEST_METADATA = {"device": "disk-test"}
6060

6161
PRINT_FN = "print_archive.sd-export"
62-
PRINT_METADATA = {
63-
"device": "printer",
64-
}
62+
PRINT_METADATA = {"device": "printer"}
6563

6664
DISK_FN = "archive.sd-export"
6765
DISK_METADATA = {"device": "disk", "encryption_method": "luks"}

securedrop_client/gui/widgets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ class SourceList(QListWidget):
784784
def __init__(self):
785785
super().__init__()
786786

787-
self.setObjectName('SourceList')
787+
self.setObjectName("SourceList")
788788
self.setUniformItemSizes(True)
789789

790790
# Set layout.
@@ -1312,7 +1312,7 @@ def _construct_message(self, source: Source) -> str:
13121312

13131313
message_tuple = (
13141314
"<big>Deleting the Source account for",
1315-
"<b>{}</b> will also".format(source.journalist_designation,),
1315+
"<b>{}</b> will also".format(source.journalist_designation),
13161316
"delete {} files, {} replies, and {} messages.</big>".format(files, replies, messages),
13171317
"<br>",
13181318
"<small>This Source will no longer be able to correspond",

securedrop_client/logic.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,7 @@ def call_api(
397397
new_api_thread.started.connect(new_api_runner.call_api)
398398

399399
# Add the thread related objects to the api_threads dictionary.
400-
self.api_threads[new_thread_id] = {
401-
"thread": new_api_thread,
402-
"runner": new_api_runner,
403-
}
400+
self.api_threads[new_thread_id] = {"thread": new_api_thread, "runner": new_api_runner}
404401

405402
# Start the thread and related activity.
406403
new_api_thread.start()
@@ -834,7 +831,7 @@ def print_file(self, file_uuid: str) -> None:
834831

835832
@login_required
836833
def on_submission_download(
837-
self, submission_type: Union[Type[db.File], Type[db.Message]], submission_uuid: str,
834+
self, submission_type: Union[Type[db.File], Type[db.Message]], submission_uuid: str
838835
) -> None:
839836
"""
840837
Download the file associated with the Submission (which may be a File or Message).

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@
3434
"Intended Audience :: Developers",
3535
"Operating System :: OS Independent",
3636
),
37-
entry_points={"console_scripts": ["sd-client = securedrop_client.app:run",],},
37+
entry_points={"console_scripts": ["sd-client = securedrop_client.app:run"]},
3838
)

tests/api_jobs/test_downloads.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def fake_download(sdk_obj: SdkSubmission, timeout: int) -> Tuple[str, str]:
364364
api_client.default_request_timeout = mocker.MagicMock()
365365
api_client.download_submission = fake_download
366366

367-
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg,)
367+
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg)
368368

369369
mock_logger = mocker.patch("securedrop_client.api_jobs.downloads.logger")
370370

@@ -407,7 +407,7 @@ def fake_download(sdk_obj: SdkSubmission, timeout: int) -> Tuple[str, str]:
407407
api_client.default_request_timeout = mocker.MagicMock()
408408
api_client.download_submission = fake_download
409409

410-
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg,)
410+
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg)
411411

412412
job.call_api(api_client, session)
413413

@@ -440,7 +440,7 @@ def fake_download(sdk_obj: SdkSubmission, timeout: int) -> Tuple[str, str]:
440440
api_client.default_request_timeout = mocker.MagicMock()
441441
api_client.download_submission = fake_download
442442

443-
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg,)
443+
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg)
444444

445445
with pytest.raises(DownloadChecksumMismatchException):
446446
job.call_api(api_client, session)
@@ -468,7 +468,7 @@ def fake_download(sdk_obj: SdkSubmission, timeout: int) -> Tuple[str, str]:
468468
api_client.default_request_timeout = mocker.MagicMock()
469469
api_client.download_submission = fake_download
470470

471-
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg,)
471+
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg)
472472

473473
mock_decrypt = patch_decrypt(mocker, homedir, gpg, file_.filename)
474474
mock_logger = mocker.patch("securedrop_client.api_jobs.downloads.logger")
@@ -512,7 +512,7 @@ def fake_download(sdk_obj: SdkSubmission, timeout: int) -> Tuple[str, str]:
512512
api_client.default_request_timeout = mocker.MagicMock()
513513
api_client.download_submission = fake_download
514514

515-
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg,)
515+
job = FileDownloadJob(file_.uuid, os.path.join(homedir, "data"), gpg)
516516

517517
with pytest.raises(DownloadDecryptionException):
518518
job.call_api(api_client, session)

tests/api_jobs/test_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_MetadataSyncJob_success(mocker, homedir, session, session_maker):
1111
job = MetadataSyncJob(homedir)
1212

1313
mock_source = factory.RemoteSource(
14-
key={"type": "PGP", "public": PUB_KEY, "fingerprint": "123456ABC",}
14+
key={"type": "PGP", "public": PUB_KEY, "fingerprint": "123456ABC"}
1515
)
1616

1717
mock_get_remote_data = mocker.patch(
@@ -33,7 +33,7 @@ def test_MetadataSyncJob_success_with_missing_key(mocker, homedir, session, sess
3333
"""
3434
job = MetadataSyncJob(homedir)
3535

36-
mock_source = factory.RemoteSource(key={"type": "PGP", "public": "", "fingerprint": "",})
36+
mock_source = factory.RemoteSource(key={"type": "PGP", "public": "", "fingerprint": ""})
3737

3838
mock_get_remote_data = mocker.patch(
3939
"securedrop_client.api_jobs.sync.get_remote_data", return_value=([mock_source], [], [])

tests/api_jobs/test_uploads.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_send_reply_success(homedir, mocker, session, session_maker, reply_statu
4848
"securedrop_client.logic.sdclientapi.Source", return_value=mock_sdk_source
4949
)
5050

51-
job = SendReplyJob(source.uuid, msg_uuid, msg, gpg,)
51+
job = SendReplyJob(source.uuid, msg_uuid, msg, gpg)
5252

5353
job.call_api(api_client, session)
5454

@@ -114,7 +114,7 @@ def test_drafts_ordering(homedir, mocker, session, session_maker, reply_status_c
114114
"securedrop_client.logic.sdclientapi.Source", return_value=mock_sdk_source
115115
)
116116

117-
job = SendReplyJob(source.uuid, msg_uuid, msg, gpg,)
117+
job = SendReplyJob(source.uuid, msg_uuid, msg, gpg)
118118

119119
job.call_api(api_client, session)
120120

@@ -175,7 +175,7 @@ def test_send_reply_failure_gpg_error(homedir, mocker, session, session_maker, r
175175
"securedrop_client.logic.sdclientapi.Source", return_value=mock_sdk_source
176176
)
177177

178-
job = SendReplyJob(source.uuid, msg_uuid, msg, gpg,)
178+
job = SendReplyJob(source.uuid, msg_uuid, msg, gpg)
179179

180180
with pytest.raises(SendReplyJobError):
181181
job.call_api(api_client, session)

tests/conftest.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def config(homedir) -> str:
126126
full_path = os.path.join(homedir, Config.CONFIG_NAME)
127127
with open(full_path, "w") as f:
128128
f.write(
129-
json.dumps({"journalist_key_fingerprint": "65A1B5FF195B56353CC63DFFCC40EF1228271441",})
129+
json.dumps({"journalist_key_fingerprint": "65A1B5FF195B56353CC63DFFCC40EF1228271441"})
130130
)
131131
return full_path
132132

@@ -186,10 +186,7 @@ def download_error_codes(session) -> None:
186186

187187
@pytest.fixture(scope="function")
188188
def source(session) -> dict:
189-
args = {
190-
"uuid": str(uuid4()),
191-
"public_key": PUB_KEY,
192-
}
189+
args = {"uuid": str(uuid4()), "public_key": PUB_KEY}
193190
source = Source(
194191
journalist_designation="foo-bar",
195192
is_flagged=False,

0 commit comments

Comments
 (0)