From 4a4e6bc95248bf04310d4479764a79efe95288aa Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 5 Jul 2024 08:51:11 +0200 Subject: [PATCH] chore: fix flake8-builtins overrides --- freqtrade/freqai/RL/BaseEnvironment.py | 2 +- freqtrade/freqai/data_drawer.py | 20 ++++++++++---------- pyproject.toml | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/freqtrade/freqai/RL/BaseEnvironment.py b/freqtrade/freqai/RL/BaseEnvironment.py index ba72c90ed..5ddfdeb68 100644 --- a/freqtrade/freqai/RL/BaseEnvironment.py +++ b/freqtrade/freqai/RL/BaseEnvironment.py @@ -52,7 +52,7 @@ class BaseEnvironment(gym.Env): reward_kwargs: dict = {}, window_size=10, starting_point=True, - id: str = "baseenv-1", + id: str = "baseenv-1", # noqa: A002 seed: int = 1, config: dict = {}, live: bool = False, diff --git a/freqtrade/freqai/data_drawer.py b/freqtrade/freqai/data_drawer.py index 37780a945..124ed9e26 100644 --- a/freqtrade/freqai/data_drawer.py +++ b/freqtrade/freqai/data_drawer.py @@ -238,9 +238,9 @@ class FreqaiDataDrawer: metadata, fp, default=self.np_encoder, number_mode=rapidjson.NM_NATIVE ) - def np_encoder(self, object): - if isinstance(object, np.generic): - return object.item() + def np_encoder(self, obj): + if isinstance(obj, np.generic): + return obj.item() def get_pair_dict_info(self, pair: str) -> Tuple[str, int]: """ @@ -448,8 +448,8 @@ class FreqaiDataDrawer: delete_dict: Dict[str, Any] = {} - for dir in model_folders: - result = pattern.match(str(dir.name)) + for directory in model_folders: + result = pattern.match(str(directory.name)) if result is None: continue coin = result.group(1) @@ -458,10 +458,10 @@ class FreqaiDataDrawer: if coin not in delete_dict: delete_dict[coin] = {} delete_dict[coin]["num_folders"] = 1 - delete_dict[coin]["timestamps"] = {int(timestamp): dir} + delete_dict[coin]["timestamps"] = {int(timestamp): directory} else: delete_dict[coin]["num_folders"] += 1 - delete_dict[coin]["timestamps"][int(timestamp)] = dir + delete_dict[coin]["timestamps"][int(timestamp)] = directory for coin in delete_dict: if delete_dict[coin]["num_folders"] > num_keep: @@ -612,9 +612,9 @@ class FreqaiDataDrawer: elif self.model_type == "pytorch": import torch - zip = torch.load(dk.data_path / f"{dk.model_filename}_model.zip") - model = zip["pytrainer"] - model = model.load_from_checkpoint(zip) + zipfile = torch.load(dk.data_path / f"{dk.model_filename}_model.zip") + model = zipfile["pytrainer"] + model = model.load_from_checkpoint(zipfile) if not model: raise OperationalException( diff --git a/pyproject.toml b/pyproject.toml index 3e04f4aad..5918e92e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,6 +134,7 @@ extend-select = [ "W", # pycodestyle "UP", # pyupgrade "I", # isort + "A", # flake8-builtins "TID", # flake8-tidy-imports # "EXE", # flake8-executable # "C4", # flake8-comprehensions