From 10c36013f0ec8ff588c53695012b504769690d15 Mon Sep 17 00:00:00 2001 From: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Date: Thu, 13 Jan 2022 20:26:27 -0500 Subject: [PATCH] Custom Linter to Check DEBUG_MODE (#1183) * Added debug_mode check * Changed pre-commit hook * Changed pre-commit hook * Fixing error * Fixed DCF tests (Sorry Didier) * Removed the br thingy * Dider changes --- .pre-commit-config.yaml | 9 +++++ custom_pre_commit/debug_mode.py | 34 +++++++++++++++++++ .../stocks/fundamental_analysis/dcf_view.py | 1 - 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 custom_pre_commit/debug_mode.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c08ed7edd8e..9fadec9601c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,13 @@ repos: + - repo: local + hooks: + - id: check-debug-mode + name: check-debug-mode + entry: python custom_pre_commit/debug_mode.py + language: python + language_version: python3 + types: ["file"] + pass_filenames: false - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 hooks: diff --git a/custom_pre_commit/debug_mode.py b/custom_pre_commit/debug_mode.py new file mode 100755 index 00000000000..36c8f38a066 --- /dev/null +++ b/custom_pre_commit/debug_mode.py @@ -0,0 +1,34 @@ +""" Check debug mode """ +__docformat__ = "numpy" + +import sys +import os +from typing import List + + +def search(lst: List[str], search_item: str): + for _, val in enumerate(lst): + if search_item in val: + return val + return None + + +def main(): + path = os.path.join( + os.path.dirname(os.path.dirname(__file__)), + "gamestonk_terminal", + "config_terminal.py", + ) + with open(path) as file: + lines = file.readlines() + lines = [line.rstrip() for line in lines] + + debug_line = search(lines, "DEBUG_MODE") + + if debug_line == "DEBUG_MODE = False": + sys.exit(0) + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/gamestonk_terminal/stocks/fundamental_analysis/dcf_view.py b/gamestonk_terminal/stocks/fundamental_analysis/dcf_view.py index 0c6903d9a3b..cb644a66767 100644 --- a/gamestonk_terminal/stocks/fundamental_analysis/dcf_view.py +++ b/gamestonk_terminal/stocks/fundamental_analysis/dcf_view.py @@ -1278,7 +1278,6 @@ class CreateExcelFA: sister_ret = [ self.get_sister_data(x, sisters[0]) for x in ["BS", "IS", "CF"] ] - print(sister_ret) blank = [x.empty for x in sister_ret] if True in blank: sisters.pop(0)