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

Enable Ruff flake8-use-pathlib (PTH) #13795

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Apr 4, 2025

Kept this one for last. Closes #13295
Some rules in this group are forcing some refactoring to use pathlib. In some cases, it's a lot cleaner, in others it's debatable.

I unconditionally followed all the rules. Please indicate changes you disagree with/preferred in the old style. I'll revert those and disable the relevant rules.

There's also a few with read and with write that can be further rewritten to be more concise with Path.read_text and Path.write_text

@Avasam Avasam marked this pull request as draft April 4, 2025 19:10
@Avasam Avasam changed the title Enable ruff flake8 use pathlib (pth) Enable Ruff flake8-use-pathlib (PTH) Apr 4, 2025
@@ -203,7 +203,7 @@ def allowlists(distribution_name: str) -> list[str]:

@functools.cache
def get_gitignore_spec() -> pathspec.PathSpec:
with open(".gitignore", encoding="UTF-8") as f:
with Path(".gitignore").open(encoding="UTF-8") as f:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer the simple open() in this and similar cases. But it's no deal breaker for me. The rest looks good.

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.

Applying more Ruff groups to this repository
3 participants