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

Automatically write .gitignore to cache dir, ignoring everything #8193

Merged
merged 3 commits into from
Jan 21, 2020

Conversation

scop
Copy link
Contributor

@scop scop commented Dec 22, 2019

Kudos to pytest for the idea.

pytest-dev/pytest#3286 (comment)

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):
Copy link
Collaborator

@ethanhs ethanhs Dec 23, 2019

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

@msullivan msullivan left a 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.
@scop
Copy link
Contributor Author

scop commented Jan 18, 2020

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.

@msullivan
Copy link
Collaborator

I'll squash it when I merge the PR, which I will do now. Thank you!

@msullivan msullivan merged commit 4f3c9cd into python:master Jan 21, 2020
@scop scop deleted the cache-dir-gitignore branch January 22, 2020 20:51
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.

3 participants