Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 9 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:
exclude: versioneer.py

- repo: https://github.com/crate-ci/typos
rev: v1.16.26
rev: typos-v0.10.21
hooks:
- id: typos
# empty to do not write fixes
Expand All @@ -56,8 +56,15 @@ repos:
# hooks:
# - id: mypy

- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
additional_dependencies:
- flake8-bandit

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.2.1
hooks:
# use black formatting
- id: ruff-format
Expand Down
4 changes: 2 additions & 2 deletions cachier/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
def _get_git_sha() -> str:
if not os.path.isdir(os.path.join(_PATH_ROOT, ".git")):
return ""
out = subprocess.check_output(
["git", "rev-parse", "HEAD"], # noqa: S603 S607
out = subprocess.check_output( # noqa: S603, S607
["git", "rev-parse", "HEAD"],
stderr=DEVNULL,
)
sha = out.decode("utf-8").strip()
Expand Down
4 changes: 2 additions & 2 deletions cachier/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def func_wrapper(*args, **kwds):
func, _is_method=core.func_is_method, args=args, kwds=kwds
)

_print = lambda x: None # skipcq: FLK-E731 # noqa: E731
_print = lambda x: None # noqa: E731
if verbose_cache:
_print = print
if ignore_cache or not _default_params["caching_enabled"]:
Expand All @@ -291,7 +291,7 @@ def func_wrapper(*args, **kwds):
_print("Cached result found.")
local_stale_after = (
stale_after or _default_params["stale_after"]
) # noqa: E501
)
local_next_time = next_time or _default_params["next_time"] # noqa: E501
now = datetime.datetime.now()
if now - entry["time"] <= local_stale_after:
Expand Down
6 changes: 3 additions & 3 deletions cachier/cores/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ def _check_calculation(self):
self.value = None
self.observer.stop()

def on_created(self, event): # skipcq: PYL-W0613
def on_created(self, event):
"""A Watchdog Event Handler method."""
self._check_calculation() # pragma: no cover

def on_modified(self, event): # skipcq: PYL-W0613
def on_modified(self, event):
"""A Watchdog Event Handler method."""
self._check_calculation()

Expand All @@ -97,7 +97,7 @@ def __init__(
else:
self.cache_dir = os.path.expanduser(
self.default_params["cache_dir"]
) # noqa: E501
)
if separate_files is not None:
self.separate_files = separate_files
else:
Expand Down
14 changes: 6 additions & 8 deletions tests/test_mongo_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ def __init__(self, mongetter):
self.create_indexes = self.collection.create_indexes
self.find_one = self.collection.find_one

def delete_many(self, *args, **kwargs): # skipcq: PYL-R0201, PYL-W0613
def delete_many(self, *args, **kwargs):
pass

def update_many(self, *args, **kwargs): # skipcq: PYL-R0201, PYL-W0613
def update_many(self, *args, **kwargs):
pass

def update_one(self, *args, **kwargs): # skipcq: PYL-R0201, PYL-W0613
def update_one(self, *args, **kwargs):
raise OperationFailure(Exception())


Expand Down Expand Up @@ -277,12 +277,10 @@ def _stalled_func():

@pytest.mark.mongo
def test_stalled_mong_db_core(monkeypatch):
def mock_get_entry(
self, args, kwargs
): # skipcq: PYL-R0201, PYL-W0613 # noqa: E501
def mock_get_entry(self, args, kwargs):
return "key", {"being_calculated": True}

def mock_get_entry_by_key(self, key): # skipcq: PYL-R0201, PYL-W0613
def mock_get_entry_by_key(self, key):
return "key", None

monkeypatch.setattr(
Expand All @@ -300,7 +298,7 @@ def _stalled_func():
res = _stalled_func()
assert res == 1

def mock_get_entry_2(self, args, kwargs): # skipcq: PYL-W0613
def mock_get_entry_2(self, args, kwargs):
entry = {
"being_calculated": True,
"value": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pickle_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def _calls_bad_cache(bad_cache_func, res_queue, trash_cache, separate_files):
cache_file.seek(0)
cache_file.truncate()
res_queue.put(res)
except Exception as exc: # skipcq: PYL-W0703
except Exception as exc:
res_queue.put(exc)


Expand Down Expand Up @@ -440,7 +440,7 @@ def _calls_delete_cache(del_cache_func, res_queue, del_cache, separate_files):
os.remove(_DEL_CACHE_FPATHS[separate_files])
# print(os.path.isfile(_DEL_CACHE_FPATH))
res_queue.put(res)
except Exception as exc: # skipcq: PYL-W0703
except Exception as exc:
# print('found')
res_queue.put(exc)

Expand Down