-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Automatically write .gitignore to cache dir, ignoring everything #8193
Conversation
mypy/build.py
Outdated
@@ -602,6 +602,12 @@ def __init__(self, data_dir: str, | |||
self.fscache = fscache | |||
self.find_module_cache = FindModuleCache(self.search_paths, self.fscache, self.options) | |||
self.metastore = create_metastore(options) | |||
if fscache.isdir(options.cache_dir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest adding the .gitignore
file only on creating the cache directory, as I wouldn't be surprised if some people store it in git intentionally. With this they would have to delete the .gitignore file every run. But I will wait for other's opinions before making this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, why not, 90013eb should take care of it. Also using os.path.isdir
instead of fscache.isdir
as metastore creates dirs without updating fscache's stat cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take this, but could you move the logic out of __init__
into a helper.
I'd also skip using the the fscache
at all here. We really just use it for source files.
Also, just try creating the file instead of doing a separate, racy existence check.
Done. I get an unrelated flake8 failure in my Travis tests, but I guess that might go away once rebased. Would you like me to do that BTW, and maybe squash the commits while at it? Not sure about the preferred PR/review flow here. |
I'll squash it when I merge the PR, which I will do now. Thank you! |
Kudos to pytest for the idea.
pytest-dev/pytest#3286 (comment)