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

Add PyUpgrade and import cleaning to Ruff #28

Merged
merged 3 commits into from
Nov 6, 2024
Merged

Conversation

knassre-bodo
Copy link
Contributor

@knassre-bodo knassre-bodo commented Nov 5, 2024

Updates the ruff usage in the pre-commit hooks to use the PyUpgrade reformatting rules, as well as the rules that tidy up imports.

[tool.ruff]
unsafe-fixes = true
lint.extend-select = [
"I", # isort
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added the other ones we use in Bodo, bc I was kinda missing the clean imports :)

@@ -14,3 +14,12 @@ dev-dependencies = ["pre-commit", "pytest", "ruff==0.6.7"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.ruff]
unsafe-fixes = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure about this part, but copied that from Bodo

@knassre-bodo knassre-bodo requested a review from njriasan November 5, 2024 21:54
@knassre-bodo knassre-bodo changed the title Add PyUpgrade to Ruff Add PyUpgrade and import cleaning to Ruff Nov 5, 2024
Copy link
Contributor

@njriasan njriasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks you @knassre-bodo

@@ -72,7 +72,7 @@ def to_tree_form(self) -> CollectionTreeForm:
)
item_str: str
if isinstance(
self.collection_access, (SubCollection, HiddenBackReferenceCollection)
self.collection_access, SubCollection | HiddenBackReferenceCollection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Srinivas opted to disable this inside Bodo because the tuple check is faster. I personally would like to disable that here as well.

"UP", # pyupgrade
"C4", # flake8-comprehensions
"TID", # flake8-tidy-imports
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add trailing newline.

@knassre-bodo knassre-bodo merged commit bdd3699 into main Nov 6, 2024
7 checks passed
@knassre-bodo knassre-bodo deleted the kian/pyupgrade branch November 6, 2024 15:11
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.

2 participants