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

Testing: Linting, Add pyupgrade and fix isort #6587

Merged
merged 13 commits into from Mar 21, 2024

Conversation

rdimaio
Copy link
Contributor

@rdimaio rdimaio commented Mar 20, 2024

Part of #6538

pyupgrade is a linter that automatically checks for deprecated syntax from older Python versions.

In this PR, pyupgrade is added to the ruff 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 fixing isort and general linting:

  • 42ab87f: extending the linter to detect Python files that it didn't previously detect, e.g. the Python files in bin/
  • 954c78a: adding the .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.
  • dd0e68e: configuring isort to see rucio 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.

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/
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 bari12 merged commit bed3f05 into rucio:master Mar 21, 2024
27 checks passed
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.

None yet

2 participants