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
Stricter code quality rules (via ruff) #488
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tony
force-pushed
the
ruff-rules
branch
2 times, most recently
from
August 4, 2023 12:08
5735ba6
to
e5c2139
Compare
tony
force-pushed
the
ruff-rules
branch
2 times, most recently
from
August 11, 2023 23:19
cf31b78
to
e4dc454
Compare
tony
force-pushed
the
ruff-rules
branch
6 times, most recently
from
August 20, 2023 10:43
d58892b
to
631d489
Compare
src/libtmux/_vendor/version.py:198:19: TRY003 Avoid specifying long messages outside the exception class"
tony
force-pushed
the
ruff-rules
branch
2 times, most recently
from
August 20, 2023 10:55
1f8ad0b
to
efcbb4a
Compare
Codecov Report
@@ Coverage Diff @@
## master #488 +/- ##
==========================================
- Coverage 88.92% 88.88% -0.04%
==========================================
Files 35 35
Lines 3484 3508 +24
Branches 484 484
==========================================
+ Hits 3098 3118 +20
- Misses 278 282 +4
Partials 108 108
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
tony
force-pushed
the
ruff-rules
branch
5 times, most recently
from
August 20, 2023 11:05
f677bb5
to
ed399aa
Compare
Fixed 81 errors: - conftest.py: 1 × I001 (unsorted-imports) - docs/conf.py: 2 × RUF100 (unused-noqa) 1 × SIM108 (if-else-block-instead-of-if-exp) 1 × I001 (unsorted-imports) - src/libtmux/_internal/query_list.py: 6 × ERA001 (commented-out-code) 1 × SIM118 (in-dict-keys) - src/libtmux/common.py: 1 × UP031 (printf-string-formatting) 1 × C408 (unnecessary-collection-call) - src/libtmux/formats.py: 2 × ERA001 (commented-out-code) - src/libtmux/neo.py: 3 × ERA001 (commented-out-code) 1 × C408 (unnecessary-collection-call) - src/libtmux/pane.py: 4 × ERA001 (commented-out-code) 4 × RUF002 (ambiguous-unicode-character-docstring) 1 × RUF005 (collection-literal-concatenation) 1 × UP032 (f-string) - src/libtmux/pytest_plugin.py: 1 × F841 (unused-variable) 1 × SIM300 (yoda-conditions) 1 × TRY201 (verbose-raise) 1 × ERA001 (commented-out-code) 1 × SIM105 (suppressible-exception) 1 × I001 (unsorted-imports) 1 × SIM118 (in-dict-keys) 1 × PERF102 (incorrect-dict-iterator) - src/libtmux/server.py: 2 × C408 (unnecessary-collection-call) 1 × RUF005 (collection-literal-concatenation) 1 × B009 (get-attr-with-constant) 1 × ERA001 (commented-out-code) - src/libtmux/session.py: 5 × C408 (unnecessary-collection-call) 2 × RUF015 (unnecessary-iterable-allocation-for-first-element) 1 × UP031 (printf-string-formatting) 1 × ERA001 (commented-out-code) 1 × UP032 (f-string) - src/libtmux/test.py: 1 × C408 (unnecessary-collection-call) - src/libtmux/window.py: 6 × UP032 (f-string) 4 × ERA001 (commented-out-code) 3 × C408 (unnecessary-collection-call) 2 × UP031 (printf-string-formatting) 1 × RUF005 (collection-literal-concatenation) 1 × RUF015 (unnecessary-iterable-allocation-for-first-element) - tests/legacy_api/test_common.py: 1 × SIM300 (yoda-conditions) - tests/legacy_api/test_server.py: 3 × SIM300 (yoda-conditions) - tests/test_common.py: 1 × SIM300 (yoda-conditions) - tests/test_pytest_plugin.py: 1 × ERA001 (commented-out-code) 1 × RUF015 (unnecessary-iterable-allocation-for-first-element) - tests/test_server.py: 3 × SIM300 (yoda-conditions)
e.g. invalid Server(color=...) argument
tony
changed the title
Ruff rules: Stricter code quality rules
Stricter code quality rules (via ruff)
Aug 20, 2023
docs/conf.py:191:9: PERF203 `try`-`except` within a loop incurs performance overhead src/libtmux/_internal/query_list.py:62:9: TRY300 Consider moving this statement to an `else` block src/libtmux/_internal/query_list.py:297:19: TRY002 Create your own exception src/libtmux/_internal/query_list.py:297:19: TRY003 Avoid specifying long messages outside the exception class src/libtmux/_internal/query_list.py:337:25: TRY301 Abstract `raise` to an inner function src/libtmux/_internal/query_list.py:337:31: TRY003 Avoid specifying long messages outside the exception class src/libtmux/common.py:154:23: TRY003 Avoid specifying long messages outside the exception class src/libtmux/common.py:191:23: TRY003 Avoid specifying long messages outside the exception class src/libtmux/common.py:246:13: TRY400 Use `logging.exception` instead of `logging.error` src/libtmux/neo.py:243:15: TRY003 Avoid specifying long messages outside the exception class src/libtmux/pane.py:293:19: TRY003 Avoid specifying long messages outside the exception class src/libtmux/pane.py:439:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/pane.py:446:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/pytest_plugin.py:230:5: TRY302 Remove exception handler; error is immediately re-raised src/libtmux/server.py:146:13: TRY300 Consider moving this statement to an `else` block src/libtmux/server.py:210:23: TRY003 Avoid specifying long messages outside the exception class src/libtmux/server.py:241:13: TRY300 Consider moving this statement to an `else` block src/libtmux/server.py:515:17: PERF401 Use a list comprehension to create a transformed list src/libtmux/server.py:535:13: PERF401 Use a list comprehension to create a transformed list src/libtmux/server.py:553:13: PERF401 Use a list comprehension to create a transformed list src/libtmux/server.py:591:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:604:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:612:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:619:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:629:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:642:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:650:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:660:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:667:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:679:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/server.py:688:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:111:17: PERF401 Use a list comprehension to create a transformed list src/libtmux/session.py:130:17: PERF401 Use a list comprehension to create a transformed list src/libtmux/session.py:361:17: PERF401 Use a list comprehension to create a transformed list src/libtmux/session.py:366:19: TRY003 Avoid specifying long messages outside the exception class src/libtmux/session.py:373:19: TRY003 Avoid specifying long messages outside the exception class src/libtmux/session.py:487:31: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` src/libtmux/session.py:602:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:609:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:616:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:623:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:633:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:640:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:649:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:657:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/session.py:666:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/test.py:50:15: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` src/libtmux/test.py:50:31: PTH120 `os.path.dirname()` should be replaced by `Path.parent` src/libtmux/test.py:51:15: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` src/libtmux/test.py:51:31: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator src/libtmux/test.py:52:33: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator src/libtmux/window.py:123:17: PERF401 Use a list comprehension to create a transformed list src/libtmux/window.py:245:31: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` src/libtmux/window.py:473:13: TRY400 Use `logging.exception` instead of `logging.error` src/libtmux/window.py:633:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/window.py:640:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/window.py:647:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/window.py:654:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/window.py:664:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/window.py:671:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/window.py:680:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/window.py:688:9: B028 No explicit `stacklevel` keyword argument found src/libtmux/window.py:697:9: B028 No explicit `stacklevel` keyword argument found tests/legacy_api/test_common.py:34:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` tests/legacy_api/test_common.py:54:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` tests/legacy_api/test_common.py:70:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` tests/legacy_api/test_common.py:87:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` tests/legacy_api/test_server.py:152:10: B017 `pytest.raises(Exception)` should be considered evil tests/test_common.py:33:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` tests/test_common.py:53:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` tests/test_common.py:69:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` tests/test_common.py:86:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` tests/test_server.py:169:10: B017 `pytest.raises(Exception)` should be considered evil tests/test_window.py:206:5: B018 Found useless expression. Either assign it to a variable or remove it.
tony
added a commit
that referenced
this pull request
Aug 20, 2023
tony
added a commit
that referenced
this pull request
Aug 20, 2023
tony
added a commit
to tmux-python/tmuxp
that referenced
this pull request
Sep 4, 2023
The boosts linting stringency and includes sorting of imports. Docs: - https://beta.ruff.rs/docs/rules/ - https://beta.ruff.rs/docs/settings/ See also: tmux-python/libtmux#488
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Docs:
Adds:
See also: tmux-python/tmuxp#879