Remove miscellaneous Python 2 anachronisms#1086
Merged
tridge merged 1 commit intoArduPilot:masterfrom Jul 11, 2025
Merged
Conversation
% `ruff check --select=UP009,UP018,UP021,UP039 --output-format=concise` ``` mavftp.py:1241:21: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) mavutil.py:940:17: UP039 [*] Unnecessary parentheses after class definition tests/snapshottests/test_wlua.py:91:9: UP021 [*] `universal_newlines` is deprecated, use `text` tools/mavfft_isb.py:75:18: UP039 [*] Unnecessary parentheses after class definition tools/mavftpdecode.py:33:16: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) tools/mavftpdecode.py:64:17: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) tools/python_array_test_recv.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary tools/python_array_test_send.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary Found 8 errors. [*] 8 fixable with the `--fix` option.` ``` localhost: ```bash source .venv/bin/activate python -m pytest # 1 failed, 50 passed, 8 skipped, 1 warning in 16.02s -- tests/test_mavftp.py OSError: Address already in use ``` ___What other testing approaches should be considered?___ ___What is our minimal supported Python? Python 3.7?___ --- % `ruff rule UP021`
e89b3b3 to
dec0140
Compare
amilcarlucas
approved these changes
Jul 8, 2025
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.
%
ruff check --select=UP009,UP018,UP021,UP039 --output-format=conciseHow was this tested?
localhost:
What other testing approaches should be considered?
What is our minimal supported Python? Python 3.7?
%
ruff rule UP021replace-universal-newlines (UP021)
Derived from the pyupgrade linter.
Fix is always available.
What it does
Checks for uses of
subprocess.runthat set theuniversal_newlineskeyword argument.
Why is this bad?
As of Python 3.7, the
universal_newlineskeyword argument has beenrenamed to
text, and now exists for backwards compatibility. Theuniversal_newlineskeyword argument may be removed in a future version ofPython. Prefer
text, which is more explicit and readable.Example
Use instead:
References
subprocess.run