mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-09 22:10:56 +08:00
Fix pylint (#888)
* add_pylint_to_workflow * fix-pylint * fix_pylinterror * fix-issue
This commit is contained in:
@@ -33,8 +33,7 @@ from ..utils import (
|
||||
|
||||
from ..log import get_module_logger
|
||||
from .base import Feature
|
||||
|
||||
from .ops import Operators
|
||||
from .ops import Operators # pylint: disable=W0611
|
||||
|
||||
|
||||
class QlibCacheException(RuntimeError):
|
||||
@@ -229,8 +228,8 @@ class CacheUtils:
|
||||
try:
|
||||
d["meta"]["last_visit"] = str(time.time())
|
||||
d["meta"]["visits"] = d["meta"]["visits"] + 1
|
||||
except KeyError:
|
||||
raise KeyError("Unknown meta keyword")
|
||||
except KeyError as key_e:
|
||||
raise KeyError("Unknown meta keyword") from key_e
|
||||
pickle.dump(d, f, protocol=C.dump_protocol_version)
|
||||
except Exception as e:
|
||||
get_module_logger("CacheUtils").warning(f"visit {cache_path} cache error: {e}")
|
||||
@@ -239,7 +238,7 @@ class CacheUtils:
|
||||
def acquire(lock, lock_name):
|
||||
try:
|
||||
lock.acquire()
|
||||
except redis_lock.AlreadyAcquired:
|
||||
except redis_lock.AlreadyAcquired as lock_acquired:
|
||||
raise QlibCacheException(
|
||||
f"""It sees the key(lock:{repr(lock_name)[1:-1]}-wlock) of the redis lock has existed in your redis db now.
|
||||
You can use the following command to clear your redis keys and rerun your commands:
|
||||
@@ -249,7 +248,7 @@ class CacheUtils:
|
||||
> quit
|
||||
If the issue is not resolved, use "keys *" to find if multiple keys exist. If so, try using "flushall" to clear all the keys.
|
||||
"""
|
||||
)
|
||||
) from lock_acquired
|
||||
|
||||
@staticmethod
|
||||
@contextlib.contextmanager
|
||||
@@ -507,7 +506,7 @@ class DiskExpressionCache(ExpressionCache):
|
||||
_instrument_dir = self.get_cache_dir(freq).joinpath(instrument.lower())
|
||||
cache_path = _instrument_dir.joinpath(_cache_uri)
|
||||
# get calendar
|
||||
from .data import Cal
|
||||
from .data import Cal # pylint: disable=C0415
|
||||
|
||||
_calendar = Cal.calendar(freq=freq)
|
||||
|
||||
@@ -599,7 +598,7 @@ class DiskExpressionCache(ExpressionCache):
|
||||
last_update_time = d["info"]["last_update"]
|
||||
|
||||
# get newest calendar
|
||||
from .data import Cal, ExpressionD
|
||||
from .data import Cal, ExpressionD # pylint: disable=C0415
|
||||
|
||||
whole_calendar = Cal.calendar(start_time=None, end_time=None, freq=freq)
|
||||
# calendar since last updated.
|
||||
@@ -753,7 +752,7 @@ class DiskDatasetCache(DatasetCache):
|
||||
if disk_cache == 0:
|
||||
# In this case, server only checks the expression cache.
|
||||
# The client will load the cache data by itself.
|
||||
from .data import LocalDatasetProvider
|
||||
from .data import LocalDatasetProvider # pylint: disable=C0415
|
||||
|
||||
LocalDatasetProvider.multi_cache_walker(instruments, fields, start_time, end_time, freq)
|
||||
return ""
|
||||
@@ -895,7 +894,7 @@ class DiskDatasetCache(DatasetCache):
|
||||
:return type pd.DataFrame; The fields of the returned DataFrame are consistent with the parameters of the function.
|
||||
"""
|
||||
# get calendar
|
||||
from .data import Cal
|
||||
from .data import Cal # pylint: disable=C0415
|
||||
|
||||
cache_path = Path(cache_path)
|
||||
_calendar = Cal.calendar(freq=freq)
|
||||
@@ -970,14 +969,14 @@ class DiskDatasetCache(DatasetCache):
|
||||
index_data = im.get_index()
|
||||
|
||||
self.logger.debug("Updating dataset: {}".format(d))
|
||||
from .data import Inst
|
||||
from .data import Inst # pylint: disable=C0415
|
||||
|
||||
if Inst.get_inst_type(instruments) == Inst.DICT:
|
||||
self.logger.info(f"The file {cache_uri} has dict cache. Skip updating")
|
||||
return 1
|
||||
|
||||
# get newest calendar
|
||||
from .data import Cal
|
||||
from .data import Cal # pylint: disable=C0415
|
||||
|
||||
whole_calendar = Cal.calendar(start_time=None, end_time=None, freq=freq)
|
||||
# The calendar since last updated
|
||||
@@ -994,7 +993,7 @@ class DiskDatasetCache(DatasetCache):
|
||||
current_index = len(whole_calendar) - len(new_calendar) + 1
|
||||
|
||||
# To avoid recursive import
|
||||
from .data import ExpressionD
|
||||
from .data import ExpressionD # pylint: disable=C0415
|
||||
|
||||
# The existing data length
|
||||
lft_etd = rght_etd = 0
|
||||
|
||||
Reference in New Issue
Block a user