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

refactor: update linting with the latest ruff #1441

Conversation

IronCore864
Copy link
Contributor

@IronCore864 IronCore864 commented Oct 22, 2024

Update linting rules with the latest ruff version 0.7.0.

After upgrading ruff to the latest version in this PR, some rules can be removed since they are not hitting any code, and some other rules can be relatively easily refactored.

@IronCore864 IronCore864 marked this pull request as ready for review October 22, 2024 01:35
@IronCore864 IronCore864 changed the title refactor: update linting with latest ruff refactor: update linting with the latest ruff Oct 22, 2024
ops/charm.py Show resolved Hide resolved
ops/_private/harness.py Show resolved Hide resolved
ops/model.py Show resolved Hide resolved
ops/_private/harness.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
@IronCore864
Copy link
Contributor Author

IronCore864 commented Oct 23, 2024

I have made some refactoring according to the reviews. Summary:

  • RUF015 (prefer next(iter(info_dicts)) over single element array/tuple) is removed from the ignore list.
  • SIM105 (use contextlib.suppress() instead of try/except: pass) is kept as it is, still ignored.
  • RUF012 (mutable class attributes should be annotated with typing.ClassVar) is removed from the ignore list. Since the emphasis is on the class attribute (instead of the instance attribute) part, not the "mutable" part, I kept the type as it is.
  • UP006 (convert Dict[X] to dict[x]) and UP007 (convert Union[X, Y] to X | Y) are removed from the ignore list because after testing without ignoring these two rules with Python 3.8, it seems there is no warning.

@dimaqq dimaqq merged commit 8145e85 into canonical:main Oct 24, 2024
30 checks passed
@IronCore864 IronCore864 deleted the refactor-after-upgrading-ruff-to-latest-version branch October 24, 2024 00:31
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.

4 participants