Skip to content

Commit 7039391

Browse files
authored
precommit: use yesqa to prune noqa (#186)
* precommit: use `yesqa` to prune noqa * apply * update
1 parent 418697c commit 7039391

6 files changed

Lines changed: 24 additions & 19 deletions

File tree

.pre-commit-config.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repos:
3131
exclude: versioneer.py
3232

3333
- repo: https://github.com/crate-ci/typos
34-
rev: v1.16.26
34+
rev: typos-v0.10.21
3535
hooks:
3636
- id: typos
3737
# empty to do not write fixes
@@ -56,8 +56,15 @@ repos:
5656
# hooks:
5757
# - id: mypy
5858

59+
- repo: https://github.com/asottile/yesqa
60+
rev: v1.5.0
61+
hooks:
62+
- id: yesqa
63+
additional_dependencies:
64+
- flake8-bandit
65+
5966
- repo: https://github.com/astral-sh/ruff-pre-commit
60-
rev: v0.1.9
67+
rev: v0.2.1
6168
hooks:
6269
# use black formatting
6370
- id: ruff-format

cachier/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
def _get_git_sha() -> str:
2222
if not os.path.isdir(os.path.join(_PATH_ROOT, ".git")):
2323
return ""
24-
out = subprocess.check_output(
25-
["git", "rev-parse", "HEAD"], # noqa: S603 S607
24+
out = subprocess.check_output( # noqa: S603, S607
25+
["git", "rev-parse", "HEAD"],
2626
stderr=DEVNULL,
2727
)
2828
sha = out.decode("utf-8").strip()

cachier/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def func_wrapper(*args, **kwds):
275275
func, _is_method=core.func_is_method, args=args, kwds=kwds
276276
)
277277

278-
_print = lambda x: None # skipcq: FLK-E731 # noqa: E731
278+
_print = lambda x: None # noqa: E731
279279
if verbose_cache:
280280
_print = print
281281
if ignore_cache or not _default_params["caching_enabled"]:
@@ -291,7 +291,7 @@ def func_wrapper(*args, **kwds):
291291
_print("Cached result found.")
292292
local_stale_after = (
293293
stale_after or _default_params["stale_after"]
294-
) # noqa: E501
294+
)
295295
local_next_time = next_time or _default_params["next_time"] # noqa: E501
296296
now = datetime.datetime.now()
297297
if now - entry["time"] <= local_stale_after:

cachier/cores/pickle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def _check_calculation(self):
6969
self.value = None
7070
self.observer.stop()
7171

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

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

@@ -97,7 +97,7 @@ def __init__(
9797
else:
9898
self.cache_dir = os.path.expanduser(
9999
self.default_params["cache_dir"]
100-
) # noqa: E501
100+
)
101101
if separate_files is not None:
102102
self.separate_files = separate_files
103103
else:

tests/test_mongo_core.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ def __init__(self, mongetter):
221221
self.create_indexes = self.collection.create_indexes
222222
self.find_one = self.collection.find_one
223223

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

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

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

233233

@@ -277,12 +277,10 @@ def _stalled_func():
277277

278278
@pytest.mark.mongo
279279
def test_stalled_mong_db_core(monkeypatch):
280-
def mock_get_entry(
281-
self, args, kwargs
282-
): # skipcq: PYL-R0201, PYL-W0613 # noqa: E501
280+
def mock_get_entry(self, args, kwargs):
283281
return "key", {"being_calculated": True}
284282

285-
def mock_get_entry_by_key(self, key): # skipcq: PYL-R0201, PYL-W0613
283+
def mock_get_entry_by_key(self, key):
286284
return "key", None
287285

288286
monkeypatch.setattr(
@@ -300,7 +298,7 @@ def _stalled_func():
300298
res = _stalled_func()
301299
assert res == 1
302300

303-
def mock_get_entry_2(self, args, kwargs): # skipcq: PYL-W0613
301+
def mock_get_entry_2(self, args, kwargs):
304302
entry = {
305303
"being_calculated": True,
306304
"value": 1,

tests/test_pickle_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _calls_bad_cache(bad_cache_func, res_queue, trash_cache, separate_files):
348348
cache_file.seek(0)
349349
cache_file.truncate()
350350
res_queue.put(res)
351-
except Exception as exc: # skipcq: PYL-W0703
351+
except Exception as exc:
352352
res_queue.put(exc)
353353

354354

@@ -440,7 +440,7 @@ def _calls_delete_cache(del_cache_func, res_queue, del_cache, separate_files):
440440
os.remove(_DEL_CACHE_FPATHS[separate_files])
441441
# print(os.path.isfile(_DEL_CACHE_FPATH))
442442
res_queue.put(res)
443-
except Exception as exc: # skipcq: PYL-W0703
443+
except Exception as exc:
444444
# print('found')
445445
res_queue.put(exc)
446446

0 commit comments

Comments
 (0)