Skip to content

Commit

Permalink
fix: ignore FileNotFoundError when removing cache dir
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoliwa committed Mar 13, 2019
1 parent 208763f commit 837bddf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions flake8_nitpick/generic.py
Original file line number Diff line number Diff line change
@@ -104,10 +104,13 @@ def rmdir_if_empty(path_or_str: PathOrStr):
return

try:
next(path.iterdir())
except StopIteration:
if path.exists():
has_items = next(path.iterdir(), False)
if has_items is False:
# If the directory has no more files/directories inside, try to remove the parent.
path.rmdir()
except FileNotFoundError:
# If any removal attempt fails, just ignore it. Some other flake8 thread might have deleted the directory.
pass


def search_dict(jmespath_expression: Union[ParsedResult, str], data: JsonDict, default: Any) -> Any:

0 comments on commit 837bddf

Please sign in to comment.