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

Enable more ruff rules #269

Merged
merged 7 commits into from
Dec 3, 2023
Merged

Enable more ruff rules #269

merged 7 commits into from
Dec 3, 2023

Conversation

skangas
Copy link
Contributor

@skangas skangas commented Dec 3, 2023

This PR enables a bunch more ruff rules. They have quite a long list of various rules, so I picked some of the more low-hanging fruit here.

Some of the fixes are arguably mostly stylistic (e.g. isort might help when merging, but doesn't do much else), but some of them might improve performance (Perflint, flake8-comprehensions), even if only slightly.

See: https://docs.astral.sh/ruff/rules/#pyupgrade-up

Fix the following new warnings:
lieer/gmailieer.py:622:23: UP030 Use implicit references for positional format fields
lieer/gmailieer.py:622:23: UP032 [*] Use f-string instead of `format` call
lieer/local.py:126:26: UP015 [*] Unnecessary open mode parameters
lieer/local.py:129:27: UP032 [*] Use f-string instead of `format` call
lieer/local.py:270:26: UP015 [*] Unnecessary open mode parameters
lieer/local.py:273:27: UP032 [*] Use f-string instead of `format` call
lieer/local.py:278:26: UP015 [*] Unnecessary open mode parameters
lieer/local.py:281:27: UP032 [*] Use f-string instead of `format` call
lieer/local.py:567:28: UP031 Use format specifiers instead of percent format
lieer/local.py:685:17: UP031 Use format specifiers instead of percent format
lieer/local.py:723:21: UP031 Use format specifiers instead of percent format
lieer/remote.py:660:25: UP031 Use format specifiers instead of percent format
lieer/remote.py:666:25: UP031 Use format specifiers instead of percent format
lieer/remote.py:673:25: UP031 Use format specifiers instead of percent format
lieer/remote.py:679:17: UP031 Use format specifiers instead of percent format
See: https://docs.astral.sh/ruff/rules/#flake8-simplify-sim

Fix the following new warnings:
lieer/gmailieer.py:941:13: SIM108 Use ternary operator `total = len(msgids) + len(previous.meta_fetched) if resume else len(msgids)` instead of `if`-`else`-block
lieer/gmailieer.py:1053:14: SIM201 [*] Use `header_recipients != cli_recipients` instead of `not header_recipients == cli_recipients`
lieer/local.py:283:24: SIM118 Use `key in dict` instead of `key in dict.keys()`
lieer/local.py:371:25: SIM115 Use context handler for opening files
lieer/remote.py:648:13: SIM102 Use a single `if` statement instead of nested `if` statements
See: https://docs.astral.sh/ruff/rules/#isort-i

Fix the following new warnings:
lieer/gmailieer.py:21:1: I001 [*] Import block is un-sorted or un-formatted
lieer/local.py:18:1: I001 [*] Import block is un-sorted or un-formatted
lieer/remote.py:18:1: I001 [*] Import block is un-sorted or un-formatted
lieer/resume.py:18:1: I001 [*] Import block is un-sorted or un-formatted
setup.py:9:1: I001 [*] Import block is un-sorted or un-formatted
tests/test_local.py:1:1: I001 [*] Import block is un-sorted or un-formatted
See: https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4

Fix the following new warnings:
lieer/local.py:55:21: C405 Unnecessary `list` literal (rewrite as a `set` literal)
lieer/local.py:205:36: C403 Unnecessary `list` comprehension (rewrite as a `set` comprehension)
lieer/local.py:213:45: C403 Unnecessary `list` comprehension (rewrite as a `set` comprehension)
lieer/local.py:351:13: C419 Unnecessary list comprehension.
lieer/remote.py:77:24: C405 Unnecessary `list` literal (rewrite as a `set` literal)
lieer/remote.py:78:22: C405 Unnecessary `list` literal (rewrite as a `set` literal)
lieer/remote.py:93:16: C405 Unnecessary `list` literal (rewrite as a `set` literal)
See: https://docs.astral.sh/ruff/rules/#perflint-perf

Fix the following new warnings:
lieer/gmailieer.py:866:17: PERF401 Use a list comprehension to create a transformed list
@gauteh gauteh merged commit e41c966 into gauteh:master Dec 3, 2023
6 checks passed
@gauteh
Copy link
Owner

gauteh commented Dec 3, 2023

Merged, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants