Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump ruff from 0.8.4 to 0.9.0 #2357

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions client/securedrop_client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def configure_logging(sdc_home: Path) -> None:
log_file = os.path.join(sdc_home, "logs", "client.log")

# set logging format
log_fmt = "%(asctime)s - %(name)s:%(lineno)d(%(funcName)s) " "%(levelname)s: %(message)s"
log_fmt = "%(asctime)s - %(name)s:%(lineno)d(%(funcName)s) %(levelname)s: %(message)s"
formatter = logging.Formatter(log_fmt)

# define log handlers such as for rotating log files
Expand Down Expand Up @@ -149,8 +149,7 @@ def arg_parser() -> ArgumentParser:
default=DEFAULT_SDC_HOME,
type=expand_to_absolute,
help=(
f"{SDC_NAME} home directory for storing files and state. "
f"(Default {DEFAULT_SDC_HOME})"
f"{SDC_NAME} home directory for storing files and state. (Default {DEFAULT_SDC_HOME})"
),
)
parser.add_argument(
Expand Down
10 changes: 3 additions & 7 deletions client/securedrop_client/gui/auth/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ def validate(self) -> None:
# Validate username
if len(username) < self.MIN_JOURNALIST_USERNAME:
self.setDisabled(False)
self.error(
_("That username won't work.\n" "It should be at least 3 characters long.")
)
self.error(_("That username won't work.\nIt should be at least 3 characters long."))
return

# Validate password
Expand All @@ -202,9 +200,7 @@ def validate(self) -> None:
int(tfa_token)
except ValueError:
self.setDisabled(False)
self.error(
_("That two-factor code won't work.\n" "It should only contain numerals.")
)
self.error(_("That two-factor code won't work.\nIt should only contain numerals."))
return
self.submit.setText(_("SIGNING IN"))

Expand All @@ -218,4 +214,4 @@ def validate(self) -> None:
self.controller.login(username, password, tfa_token)
else:
self.setDisabled(False)
self.error(_("Please enter a username, passphrase and " "two-factor code."))
self.error(_("Please enter a username, passphrase and two-factor code."))
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ class PreflightPage(ExportWizardPage):
def __init__(self, export: Export, summary: str) -> None:
self._should_autoskip_preflight = False
self.summary = summary
header = _(
"Preparing to export:<br />" '<span style="font-weight:normal">{}</span>'
).format(summary)
header = _('Preparing to export:<br /><span style="font-weight:normal">{}</span>').format(
summary
)
body = _(
"<h2>Understand the risks before exporting files</h2>"
"<b>Malware</b>"
Expand Down Expand Up @@ -285,7 +285,7 @@ def should_autoskip_preflight(self) -> bool:
def on_status_received(self, status: ExportStatus) -> None:
self.status = status
self.stop_animate_header()
header = _("Ready to export:<br />" '<span style="font-weight:normal">{}</span>').format(
header = _('Ready to export:<br /><span style="font-weight:normal">{}</span>').format(
self.summary
)
self.header.setText(header)
Expand Down Expand Up @@ -326,7 +326,7 @@ class InsertUSBPage(ExportWizardPage):
def __init__(self, export: Export, summary: str) -> None:
self.no_device_hint = 0
self.summary = summary
header = _("Ready to export:<br />" '<span style="font-weight:normal">{}</span>').format(
header = _('Ready to export:<br /><span style="font-weight:normal">{}</span>').format(
summary
)
body = _(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def __init__(self, device: Export, file_name: str, filepaths: list[str]) -> None

# Dialog content
self.starting_header = _(
"Preparing to print:<br />" '<span style="font-weight:normal">{}</span>'
'Preparing to print:<br /><span style="font-weight:normal">{}</span>'
).format(self.file_name)
self.ready_header = _(
"Ready to print:<br />" '<span style="font-weight:normal">{}</span>'
'Ready to print:<br /><span style="font-weight:normal">{}</span>'
).format(self.file_name)
self.insert_usb_header = _("Connect USB printer")
self.error_header = _("Printing failed")
Expand Down
72 changes: 36 additions & 36 deletions client/tests/functional/test_export_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ def test_export_wizard_device_locked(
functional_test_logged_in_context, qtbot, mocker, mock_export_locked
)

assert isinstance(
export_wizard.currentPage(), PreflightPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), PreflightPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)

assert export_wizard.current_status == ExportStatus.NO_DEVICE_DETECTED

def check_insert_usb_page():
assert isinstance(
export_wizard.currentPage(), InsertUSBPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), InsertUSBPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)

# Move to "insert usb" screen
qtbot.mouseClick(export_wizard.next_button, Qt.LeftButton)
Expand All @@ -115,9 +115,9 @@ def check_insert_usb_page():
assert export_wizard.current_status == ExportStatus.NO_DEVICE_DETECTED

def check_password_page():
assert isinstance(
export_wizard.currentPage(), PassphraseWizardPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), PassphraseWizardPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)

# Move to "unlock usb" screen - TODO this is an extra click?
qtbot.mouseClick(export_wizard.next_button, Qt.LeftButton)
Expand All @@ -143,9 +143,9 @@ def check_password_page():

assert export_wizard.current_status == ExportStatus.SUCCESS_EXPORT

assert isinstance(
export_wizard.currentPage(), FinalPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), FinalPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)


@flaky
Expand All @@ -164,9 +164,9 @@ def test_export_wizard_device_already_unlocked(
functional_test_logged_in_context, qtbot, mocker, mock_export_unlocked
)

assert isinstance(
export_wizard.currentPage(), PreflightPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), PreflightPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)

assert export_wizard.current_status == ExportStatus.DEVICE_WRITABLE

Expand Down Expand Up @@ -202,9 +202,9 @@ def test_export_wizard_no_device_then_bad_passphrase(
mock_export_no_usb_then_bad_passphrase,
)

assert isinstance(
export_wizard.currentPage(), PreflightPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), PreflightPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)

assert export_wizard.current_status == ExportStatus.NO_DEVICE_DETECTED

Expand All @@ -218,9 +218,9 @@ def is_unlock_page():
assert export_wizard.current_status == ExportStatus.NO_DEVICE_DETECTED

def check_password_page():
assert isinstance(
export_wizard.currentPage(), PassphraseWizardPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), PassphraseWizardPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)

# Move to "unlock usb" screen
qtbot.mouseClick(export_wizard.next_button, Qt.LeftButton)
Expand All @@ -243,9 +243,9 @@ def check_password_page_with_error_details():
After an incorrect password, the 'error details' should be visible
with a message about incorrect passphrase.
"""
assert isinstance(
export_wizard.currentPage(), PassphraseWizardPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), PassphraseWizardPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)
assert export_wizard.currentPage().error_details.isVisible()

# Click Next - Passphrase error appears
Expand All @@ -268,9 +268,9 @@ def check_password_page_with_error_details():

assert export_wizard.current_status == ExportStatus.SUCCESS_EXPORT

assert isinstance(
export_wizard.currentPage(), FinalPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), FinalPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)


@flaky
Expand All @@ -290,9 +290,9 @@ def test_export_wizard_error(
functional_test_logged_in_context, qtbot, mocker, mock_export_fail_early
)

assert isinstance(
export_wizard.currentPage(), PreflightPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), PreflightPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)

assert export_wizard.current_status == ExportStatus.NO_DEVICE_DETECTED

Expand All @@ -306,9 +306,9 @@ def is_unlock_page():
assert export_wizard.current_status == ExportStatus.NO_DEVICE_DETECTED

def check_password_page():
assert isinstance(
export_wizard.currentPage(), PassphraseWizardPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), PassphraseWizardPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)

# Move to "Enter passphrase" screen
qtbot.mouseClick(export_wizard.next_button, Qt.LeftButton)
Expand All @@ -327,7 +327,7 @@ def check_password_page():
qtbot.wait(TIME_CLICK_ACTION)
assert export_wizard.current_status == ExportStatus.ERROR_MOUNT

assert isinstance(
export_wizard.currentPage(), ErrorPage
), f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
assert isinstance(export_wizard.currentPage(), ErrorPage), (
f"Actual: {export_wizard.currentPage()} ({export_wizard.currentId()})"
)
assert export_wizard.current_status == ExportStatus.ERROR_MOUNT
4 changes: 2 additions & 2 deletions client/tests/gui/base/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ def test_SecureQLabel_init_wordwrap(mocker):
Regression test to make sure we don't remove newlines.
"""
long_string = (
"1234567890123456789012345678901234567890123456789012345678901234567890\n" "12345678901"
"1234567890123456789012345678901234567890123456789012345678901234567890\n12345678901"
)
sl = SecureQLabel(long_string, wordwrap=False)
assert sl.text() == long_string


def test_SecureQLabel_init_no_wordwrap(mocker):
long_string = (
"1234567890123456789012345678901234567890123456789012345678901234567890\n" "12345678901"
"1234567890123456789012345678901234567890123456789012345678901234567890\n12345678901"
)
sl = SecureQLabel(long_string, wordwrap=False)
assert sl.text() == long_string
Expand Down
6 changes: 3 additions & 3 deletions client/tests/gui/conversation/export/test_export_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def test_wizard_exports_directly_to_unlocked_device(self, qtbot):
self.mock_export.export_state_changed.emit(ExportStatus.DEVICE_WRITABLE)
self.wizard.next()

assert isinstance(
self.wizard.currentPage(), FinalPage
), f"Actually, f{type(self.wizard.currentPage())}"
assert isinstance(self.wizard.currentPage(), FinalPage), (
f"Actually, f{type(self.wizard.currentPage())}"
)

def test_wizard_rewinds_if_device_removed(self, qtbot):
self.wizard.show()
Expand Down
6 changes: 3 additions & 3 deletions client/tests/gui/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def test_deletes_source_when_dialog_accepted(self):
self.action.trigger()

self._controller.delete_sources.assert_called_once()
assert (
self._source in self._controller.delete_sources.call_args[0][0]
), self._controller.delete_sources.call_args[0][0]
assert self._source in self._controller.delete_sources.call_args[0][0], (
self._controller.delete_sources.call_args[0][0]
)

def test_does_not_delete_source_when_dialog_rejected(self):
# Reject the confirmation dialog from a separate thread.
Expand Down
6 changes: 3 additions & 3 deletions client/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def test_Device_run_printer_preflight_checks(self):
self.device.run_printer_preflight_checks()

mock_qproc.start.assert_called_once()
assert (
mock_qproc.start.call_args[0] == _QREXEC_EXPORT_COMMAND
), f"Actual: {mock_qproc.start.call_args[0]}"
assert mock_qproc.start.call_args[0] == _QREXEC_EXPORT_COMMAND, (
f"Actual: {mock_qproc.start.call_args[0]}"
)

def test_Device_run_print_preflight_checks_with_error(self):
spy = QSignalSpy(self.device.print_preflight_check_failed)
Expand Down
2 changes: 1 addition & 1 deletion client/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,7 @@ def test_delete_local_conversation_by_uuid_nosuchuuid(homedir, mocker, session):

delete_local_conversation_by_source_uuid(session, mock_uuid, data_dir)
error_logger.assert_called_once_with(
f"Tried to delete source {mock_uuid}, but UUID " "was not found"
f"Tried to delete source {mock_uuid}, but UUID was not found"
)


Expand Down
2 changes: 1 addition & 1 deletion export/securedrop_export/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _configure_logging():
log_file = os.path.join(DEFAULT_HOME, LOG_DIR_NAME, EXPORT_LOG_FILENAME)

# set logging format
log_fmt = "%(asctime)s - %(name)s:%(lineno)d(%(funcName)s) " "%(levelname)s: %(message)s"
log_fmt = "%(asctime)s - %(name)s:%(lineno)d(%(funcName)s) %(levelname)s: %(message)s"
formatter = logging.Formatter(log_fmt)

handler = TimedRotatingFileHandler(log_file)
Expand Down
40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "AGPLv3+"
python = "^3.11"

[tool.poetry.group.dev.dependencies]
ruff = "^0.8.4"
ruff = "^0.9.0"
safety = "*"
shellcheck-py = "*"
zizmor = "*"
Expand Down
Loading