File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 3
3
4
4
import json
5
5
import sys
6
+ from contextlib import suppress
6
7
from pathlib import Path
7
8
from typing import Any
8
9
from typing import Callable
@@ -45,22 +46,19 @@ def pytask_extend_command_line_interface(cli: click.Group) -> None:
45
46
@hookimpl
46
47
def pytask_post_parse (config : dict [str , Any ]) -> None :
47
48
"""Fill cache of file hashes with stored hashes."""
48
- try :
49
+ with suppress ( Exception ) :
49
50
path = config ["root" ] / ".pytask" / "file_hashes.json"
50
51
cache = json .loads (path .read_text ())
51
- except Exception : # noqa: BLE001
52
- cache = {}
53
52
54
- for key , value in cache .items ():
55
- HashPathCache .add (key , value )
53
+ for key , value in cache .items ():
54
+ HashPathCache .add (key , value )
56
55
57
56
58
57
@hookimpl
59
58
def pytask_unconfigure (session : Session ) -> None :
60
59
"""Save calculated file hashes to file."""
61
- path = session .config ["root" ] / ".pytask"
62
- path .mkdir (exist_ok = True , parents = True )
63
- path .joinpath ("file_hashes.json" ).write_text (json .dumps (HashPathCache ._cache ))
60
+ path = session .config ["root" ] / ".pytask" / "file_hashes.json"
61
+ path .write_text (json .dumps (HashPathCache ._cache ))
64
62
65
63
66
64
def build ( # noqa: C901, PLR0912, PLR0913
You can’t perform that action at this time.
0 commit comments