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

Update Python.gitignore for .ruff_cache/ #4289

Merged
merged 2 commits into from
Jan 17, 2025
Merged

Conversation

csauge
Copy link
Contributor

@csauge csauge commented May 1, 2023

Add Ruff cache in gitignore.
Ruff is becoming a very popular tool often run in pre-commit and aim to replace Flake8 (plus dozens of plugins), isort, pydocstyle, yesqa, eradicate, pyupgrade, and autoflake, all while executing tens or hundreds of times faster than any individual tool.

Reasons for making this change:
Ruff is run in pre-commit thus .ruff_cache/ could be included accidently in git.
Actually this is similar to .mypy_cache/ which is also run in pre-commit.

Links to documentation supporting these rule changes:
https://github.com/charliermarsh/ruff in section configuration we can see the exclude of .ruff_cache and .mypy_cache

Add ruff cache. 
ruff tool: https://github.com/charliermarsh/ruff
ruff is becoming a very popular tool often run in pre-commit and aim to replace Flake8 (plus dozens of plugins), isort, pydocstyle, yesqa, eradicate, pyupgrade, and autoflake, all while executing tens or hundreds of times faster than any individual tool.
@covracer
Copy link

See also #4199

@JasperJuergensen
Copy link

I think this is not required, as ruff will add a .gitignore file to the .ruff_cache folder with * as content effectively ignoring the folder.

See astral-sh/ruff#204 and astral-sh/ruff#208

@stdedos
Copy link

stdedos commented Oct 14, 2023

It is nicer to have it there.

e.g. PyCharm's excluded folders (and https://plugins.jetbrains.com/plugin/17288-foldable-projectview) work based on these ignores

@paduszyk
Copy link

paduszyk commented Nov 7, 2023

@JasperJuergensen pytest does the same - it also adds .gitignore with * to its cache dir. But .pytest_cache it's included in the template... The same regards nox, for instance.

@stankudrow
Copy link

stankudrow commented Jan 14, 2024

I agree that it is nice to have the .ruff_cache directory included like .mypy_cache and .pytest_cache. The ruff project is steadily developing and becoming widespread, so it is good to have it on board.

Also was mentioned in #4199 and #4274 PRs.

For instance, without the .ruff_cache line in my .gitignore file this directory is not grayed:
ruff_cache_not_ignored

When added:
ruff_cache_ignored

@abelcheung
Copy link

Other tools like mypy and pytest indeed do add their own .gitignore as a fallback measure, in case top level .gitignore doesn't handle them. But in terms of performance it is always better to add those dirs to top level .gitigore, rather than descending into cache folders and read .gitignore there. And there is visual cue differences noted above.

@stdedos
Copy link

stdedos commented Nov 4, 2024

Can we get some maintainer focus? e.g. @dooleydevin?

Copy link
Collaborator

@dooleydevin dooleydevin left a comment

Choose a reason for hiding this comment

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

Sorry for the late feedback! LGTM and will :shipit: with the next update of our templates 😄

I'll handle the merge conflicts here too just to move things along since this PR is a bit old.

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.

10 participants