fixed deepsource.io issues

This commit is contained in:
Shay Palachy
2019-12-09 17:21:56 +02:00
parent f16b5680ce
commit 5f15026ba4
3 changed files with 16 additions and 15 deletions
+7 -5
View File
@@ -23,7 +23,7 @@ from .base_core import _BaseCore
try:
FileNotFoundError
except NameError: # we're on python 2
FileNotFoundError = IOError
FileNotFoundError = IOError # skipcq: PYL-W0622
DEF_CACHIER_DIR = '~/.cachier/'
@@ -80,10 +80,10 @@ class _PickleCore(_BaseCore):
self.value = None
self.observer.stop()
def on_created(self, event):
def on_created(self, event): # skipcq: PYL-W0613
self._check_calculation() # pragma: no cover
def on_modified(self, event):
def on_modified(self, event): # skipcq: PYL-W0613
self._check_calculation()
def __init__(self, stale_after, next_time, reload, cache_dir):
@@ -95,16 +95,18 @@ class _PickleCore(_BaseCore):
self.cache_dir = cache_dir
self.expended_cache_dir = os.path.expanduser(self.cache_dir)
self.lock = threading.RLock()
self.cache_fname = None
self.cache_fpath = None
def _cache_fname(self):
if not hasattr(self, 'cache_fname'):
if self.cache_fname is None:
self.cache_fname = '.{}.{}'.format(
self.func.__module__, self.func.__name__
)
return self.cache_fname
def _cache_fpath(self):
if not hasattr(self, 'cache_fpath'):
if self.cache_fpath is None:
# print(EXPANDED_CACHIER_DIR)
if not os.path.exists(self.expended_cache_dir):
os.makedirs(self.expended_cache_dir)
+1 -2
View File
@@ -1,4 +1,4 @@
"A command-line interface for cachier."
"""A command-line interface for cachier."""
import click
@@ -8,7 +8,6 @@ from cachier.core import _set_max_workers
@click.group()
def cli():
"""A command-line interface for cachier."""
pass
@cli.command("Limits the number of worker threads used by cachier.")
+8 -8
View File
@@ -1,10 +1,10 @@
"""Testing the MongoDB core of cachier."""
from __future__ import print_function
import datetime
import sys
from random import random
import datetime
from datetime import timedelta
from random import random
from time import sleep
import threading
try:
@@ -148,14 +148,14 @@ class _BadMongoCollection:
self.create_indexes = self.collection.create_indexes
self.find_one = self.collection.find_one
def delete_many(self, *args, **kwargs): # skipcq: PYL-R0201
def delete_many(self, *args, **kwargs): # skipcq: PYL-R0201, PYL-W0613
pass
def update_many(self, *args, **kwargs): # skipcq: PYL-R0201
def update_many(self, *args, **kwargs): # skipcq: PYL-R0201, PYL-W0613
pass
def update_one(self, *args, **kwargs): # skipcq: PYL-R0201
def update_one(self, *args, **kwargs): # skipcq: PYL-R0201, PYL-W0613
raise OperationFailure(Exception())
@@ -195,10 +195,10 @@ def test_stalled_mongo_db_cache():
def test_stalled_mong_db_core(monkeypatch):
def mock_get_entry(self, args, kwargs): # skipcq: PYL-R0201
def mock_get_entry(self, args, kwargs): # skipcq: PYL-R0201, PYL-W0613
return "key", {'being_calculated': True}
def mock_get_entry_by_key(self, key): # skipcq: PYL-R0201
def mock_get_entry_by_key(self, key): # skipcq: PYL-R0201, PYL-W0613
return "key", None
monkeypatch.setattr(
@@ -213,7 +213,7 @@ def test_stalled_mong_db_core(monkeypatch):
res = _stalled_func()
assert res == 1
def mock_get_entry_2(self, args, kwargs):
def mock_get_entry_2(self, args, kwargs): # skipcq: PYL-W0613
entry = {
'being_calculated': True,
"value": 1,