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 .ruff_cache/ to .gitignore #110983

Merged
merged 1 commit into from Oct 17, 2023
Merged

Conversation

sobolevn
Copy link
Member

ruff uses this folder for some cache-related stuff, we ignore similar folders in this project.

See https://docs.astral.sh/ruff/settings/#cache-dir

AlexWaygood
AlexWaygood previously approved these changes Oct 17, 2023
@hugovk
Copy link
Member

hugovk commented Oct 17, 2023

Is this needed? They already contain their own .gitignore:

cat .ruff_cache/.gitignore
*cat ./Lib/test/.ruff_cache/.gitignore
*

@AlexWaygood
Copy link
Member

Is this needed? They already contain their own .gitignore:

❯ cat .ruff_cache/.gitignore
*
❯ cat ./Lib/test/.ruff_cache/.gitignore
*

Ah, good point. Yes, I seem to have a .ruff_cache directory locally inside my cpython clone, but it doesn't show up when I do git status.

@sobolevn
Copy link
Member Author

I think that different tools treat * a bit differently, for example, my editor shows that .ruff_cache folder is not ignored, but its content is ignored:
Снимок экрана 2023-10-17 в 16 57 12

Compare colors with build/ which is fully ignored.

@AlexWaygood
Copy link
Member

AlexWaygood commented Oct 17, 2023

I think that different tools treat * a bit differently, for example, my editor [...]

I feel like tools should probably parse .gitignore files the same way git does? This feels like it's maybe something that should be reported as a bug to your editor

@sobolevn
Copy link
Member Author

Looks like VSCode is consistent with git check-ignore

~/Desktop/cpython  main ✔                                                                 
» git check-ignore -v .ruff_cache
                                                                                           
~/Desktop/cpython  main ✔                                                              1 ⚠️
» git checkout ruff-cache-ignore                       
Switched to branch 'ruff-cache-ignore'
Your branch is up to date with 'fork/ruff-cache-ignore'.
                                                                                           
~/Desktop/cpython  ruff-cache-ignore ✔                                                    
» git check-ignore -v .ruff_cache
.gitignore:45:.ruff_cache/      .ruff_cache

I don't really care enough about this change to continue this discussion.

@AlexWaygood
Copy link
Member

yeah, I don't really care too much either. If git check-ignore says .ruff_cache isn't ignored (even though everything in it is), and this change helps out VSCode users, that's good enough for me. One extra line in .gitignore isn't a massive maintenance burden ;)

I'll wait to see if @hugovk agrees, though.

@hugovk
Copy link
Member

hugovk commented Oct 17, 2023

Sure, fine to add it.

But now I'm curious...


build is ignored by the top-level .gitignore:

git check-ignore -v build
.gitignore:119:/build/	build

The .ruff_cache directory isn't ignored.

git check-ignore -v .ruff_cache

But Git only tracks files, not directories!

And the files in that directory are correctly ignored:

git check-ignore -v .ruff_cache/CACHEDIR.TAG
.ruff_cache/.gitignore:1:*	.ruff_cache/CACHEDIR.TAG

So that all tracks.


I just installed VSCode, but nothing is showing as ignored. Do you need to do something to enable Git ignoring?

image

With PyCharm you need to open a relevant .gitignore file and tell it to ignore the contents. Here we see some orange dirs ignored, but not the Ruff one:

image

@sobolevn
Copy link
Member Author

( sorry, I am preparing a conference talk, so I cannot continue digging :( )

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Good luck with the prep!

@AlexWaygood AlexWaygood merged commit 0f9d0fb into python:main Oct 17, 2023
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants