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
Testing: Linting, Add pyupgrade and fix isort #6587
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
UTF-8 is the default source encoding in Python 3. Declaring it is unncessary, unless Python 2 is also supported. See also: - https://peps.python.org/pep-3120/ - https://docs.python.org/3/howto/unicode.html#python-s-unicode-support - https://stackoverflow.com/questions/14083111/should-i-use-encoding-declaration-in-python-3
UTF-8 is the default source encoding in Python 3. Declaring it is unncessary, unless Python 2 is also supported. See also: - https://peps.python.org/pep-3120/ - https://docs.python.org/3/howto/unicode.html#python-s-unicode-support - https://stackoverflow.com/questions/14083111/should-i-use-encoding-declaration-in-python-3
Since Python 3, all classes inherit from object by default, so object can be omitted from the list of base classes. See also: - https://docs.astral.sh/ruff/rules/useless-object-inheritance/ - https://peps.python.org/pep-3115/
In Python3.3+, a variety of exceptions (such as IOError) were aliased to OSError, with the latter being the preferred exception to use. See also: - https://docs.python.org/3/library/exceptions.html#OSError - https://stackoverflow.com/questions/29347790/difference-between-ioerror-and-oserror - https://docs.astral.sh/ruff/rules/os-error-alias/
See also: - UP034
UTF-8 is the default encoding in Python, so there is no need to call encode when UTF-8 is the desired encoding. Instead, use a bytes literal. See also: - https://docs.astral.sh/ruff/rules/unnecessary-encode-utf8/
Pyupgrade is a linter to check for deprecated Python syntax. This commit configures ruff to perform pyupgrade linting. In the ignore list, I added some pyupgrade error codes (UP*) for the moment. These must either be fixed manually, or might be controversial in some way, so we can consider them at a later point.
…ucio#6538 rucio is detected as a third-party dependency by default (likely has to do with the project structure or __init__ files). This change configures isort to treat rucio as a first-party dependency, and re-formats the files.
bari12
approved these changes
Mar 21, 2024
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.
Part of #6538
pyupgrade
is a linter that automatically checks for deprecated syntax from older Python versions.In this PR,
pyupgrade
is added to theruff
linter. Each separate pyupgrade-related change is broken down in its own commit, for ease of review. Most of the commits here have a longer description message you can check, which explains the reasoning behind that particular change, as well as some useful links.The final three commits that are not related to
pyupgrade
, but to fixingisort
and general linting:bin/
.py
extension to a Python script that was not being detected by the linter. This script is not used anywhere else in the repository - I think @bari12 is the main user of this script, and I checked with him before doing this change.isort
to seerucio
as a first-party package: previously, it erroneously considered it to be a third-party package, likely due to either the project structure or to__init__
file-related issues.Feel free to discuss with me in case you need more info to review this - I realize it seems like a pretty bulky PR, but it becomes much easier to review when reviewed commit-by-commit.