I'm no ruff expert, but I do see some low hanging fruit that can be automatically detected and easily fixed with some very small edits to this section of your pyproject.toml file:
|
[tool.ruff.lint] |
|
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. |
|
# Enable flagging print (T201) |
|
select = ["E", "F", "T201"] |
"PERF" rules
If we enable the "PERF" (performance) rules, we can detect the following 1 issue:
PERF401 Use `list.extend` to create a transformed list
--> src/thunderbird_accounts/core/views.py:79:17
|
77 | # Get user's app passwords from Stalwart, excluding internal ones
78 | for secret in filter_app_passwords(email_user.get('secrets', [])):
79 | app_passwords.append(decode_app_password(secret))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80 |
81 | # Get user's email addresses from Stalwart
|
help: Replace for loop with list.extend
Found 1 error.
You can read about this rule here: https://docs.astral.sh/ruff/rules/manual-list-comprehension/
"FURB" rules
Similarly, if we enable the "FURB" rules, you can find 3 issues:
FURB188 Prefer `str.removeprefix()` over conditionally replacing with slice.
--> docs/conf.py:109:9
|
108 | # Depending on where the docs are built from this could be slightly different...
109 | / if file.startswith('../'):
110 | | file = file[3:]
| |___________________________^
111 |
112 | if not file.startswith('src/thunderbird_accounts'):
|
help: Use removeprefix instead of assignment conditional upon startswith.
FURB110 Replace ternary `if` expression with `or` operator
--> src/thunderbird_accounts/authentication/views.py:157:22
|
155 | sentry_sdk.capture_exception(ex)
156 | messages.error(
157 | request, ex.error_desc if ex.error_desc else _('There was an unknown error, please try again later.')
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158 | )
159 | return HttpResponseRedirect('/sign-up')
|
help: Replace with `or` operator
FURB110 Replace ternary `if` expression with `or` operator
--> src/thunderbird_accounts/core/views.py:126:32
|
124 | 'app_passwords': json.dumps(app_passwords),
125 | 'user_display_name': user_display_name,
126 | 'allowed_domains': settings.ALLOWED_EMAIL_DOMAINS if settings.ALLOWED_EMAIL_DOMAINS else [],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127 | 'custom_domains': json.dumps(custom_domains),
128 | 'email_addresses': json.dumps(email_addresses),
|
help: Replace with `or` operator
Found 3 errors.
You can read about these rule here:
I'm no
ruffexpert, but I do see some low hanging fruit that can be automatically detected and easily fixed with some very small edits to this section of yourpyproject.tomlfile:thunderbird-accounts/pyproject.toml
Lines 124 to 127 in 447086a
"PERF"rulesIf we enable the
"PERF"(performance) rules, we can detect the following 1 issue:You can read about this rule here: https://docs.astral.sh/ruff/rules/manual-list-comprehension/
"FURB"rulesSimilarly, if we enable the
"FURB"rules, you can find 3 issues:You can read about these rule here: