Skip to content

Commit

Permalink
Address new ruff errors
Browse files Browse the repository at this point in the history
* Use .items() when extracting a value from a dictionary
* Suppress two instances where we don't use a context-manager when
  opening a temporary file as it wouldn't really help.
  • Loading branch information
legoktm committed Dec 20, 2024
1 parent 61fe949 commit 4fdd09b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/securedrop_client/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def decrypt_submission_or_reply(
"""
original_filename = Path(Path(filepath).stem).stem # Remove one or two suffixes

err = tempfile.NamedTemporaryFile(suffix=".message-error", delete=False)
err = tempfile.NamedTemporaryFile(suffix=".message-error", delete=False) # noqa: SIM115
with tempfile.NamedTemporaryFile(suffix=".message") as out:
cmd = self._gpg_cmd_base()
cmd.extend(["--decrypt", filepath])
Expand Down
4 changes: 2 additions & 2 deletions client/securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,9 @@ def update_sources(self, sources: list[Source]) -> list[str]:
source_widget.reload()

# Add widgets for new sources
for uuid in sources_to_add:
for uuid, source in sources_to_add.items():
source_widget = SourceWidget(
self.controller, sources_to_add[uuid], self.source_selected, self.adjust_preview
self.controller, source, self.source_selected, self.adjust_preview
)
source_item = SourceListWidgetItem(self)
source_item.setSizeHint(source_widget.sizeHint())
Expand Down
2 changes: 1 addition & 1 deletion client/securedrop_client/sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _rpc_target(self) -> list:
def _streaming_download(
self, data: dict[str, Any], env: dict
) -> StreamedResponse | JSONResponse:
fobj = tempfile.TemporaryFile("w+b")
fobj = tempfile.TemporaryFile("w+b") # noqa: SIM115

retry = 0
bytes_written = 0
Expand Down

0 comments on commit 4fdd09b

Please sign in to comment.