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

Always write the cache (unless cache_dir is /dev/null) #3133

Merged
merged 6 commits into from
Apr 19, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,10 @@ def write_cache(id: str, path: str, tree: MypyFile,

# Make sure directory for cache files exists
parent = os.path.dirname(data_json)
if not os.path.isdir(parent):
try:
os.makedirs(parent)
except os.error:
pass # Assume it already exists.
Copy link
Member

Choose a reason for hiding this comment

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

You can just call os.makedirs(parent, exist_ok=True) instead (as of 3.2, https://docs.python.org/3/library/os.html#os.makedirs).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh thanks! Why this isn't the default behavior I'll never understand (it's Eric Raymond's fault :-).

assert os.path.dirname(meta_json) == parent

# Construct temp file names
Expand Down