Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #560 +/- ##
==========================================
- Coverage 88.68% 88.65% -0.04%
==========================================
Files 36 36
Lines 3924 3922 -2
Branches 362 362
==========================================
- Hits 3480 3477 -3
Misses 307 307
- Partials 137 138 +1 ☔ View full report in Codecov by Sentry. |
Reviewer's Guide by SourceryThis pull request refactors the Sequence diagram for simplified tmux_cmd execution flowsequenceDiagram
participant C as Client Code
participant T as tmux_cmd
participant S as subprocess.run
C->>+T: Execute tmux command
T->>T: Convert args to strings
T->>+S: Run command with text=True
S-->>-T: Return stdout/stderr as text
T->>T: Process stdout/stderr
T-->>-C: Return processed results
Class diagram showing tmux_cmd changesclassDiagram
class TmuxCommandResponse {
+list[str] stdout
+list[str] stderr
+int returncode
+list[str] cmd
+__init__(args)
}
note for TmuxCommandResponse "Removed console_to_str usage
Now uses text=True in subprocess.run"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
10b03d7 to
1a5e69a
Compare
With `text=True` being used we can now wrap in `str()` for bytes to be handled as `str`.
Member
Author
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey @tony - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider removing the unused 'reraise' function as well since it's not called anywhere (as noted in the TODO comment). This would further help in cleaning up legacy code.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
More resilience for `tmux` command across systems. Ability to debug because escape sequences preserves the byte value for debugging.
8ac9fe6 to
2a4901d
Compare
tmux_cmd: Remove reliance on console_to_strtmux_cmd: Modernize to use text=True
tony
added a commit
that referenced
this pull request
Feb 2, 2025
tony
added a commit
to tmux-python/tmuxp
that referenced
this pull request
Feb 2, 2025
) ## py(deps) libtmux 0.40.1 -> 0.42.0 - tree: https://github.com/tmux-python/libtmux/tree/v0.42.0 - releases: https://github.com/tmux-python/libtmux/releases/tag/v0.42.0 - changelog: https://libtmux.git-pull.com/history.html#libtmux-0-42-0-2025-02-02 - PyPI: https://pypi.org/project/libtmux/0.42.0/ ## run_before_script: Remove reliance on `console_to_str()` See also: tmux-python/libtmux#560
This file contains hidden or 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
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.
This is a legacy function dating back to Python 2.x and was derived from pip.
See: #558
Changes
tmux_cmd: Usetext=Trueinsubprocess.runSee also:
tmux_cmd: Remove usage ofconsole_to_str()This is a legacy function dating back to Python 2.x and was derived from pip.
text=Truemakes this unneeded.tmux_cmd: Remove usage ofstr_from_console()Originally from #131. In combination with
text=Trueused intmux_cmdthis is unneeded.compat: Remove
console_to_str()andstr_from_console()Unused.
Summary by Sourcery
Update the
tmux_cmdfunction to use thetext=Trueargument insubprocess.run, simplifying the function by removing the dependency on legacy encoding functions, and removing now-unused encoding functions.Enhancements:
tmux_cmdby removing the dependency on the legacyconsole_to_strfunction and using built-in string conversion.Tests:
tmux_cmdand ensure compatibility with Python 3.