Skip to content

Commit

Permalink
Added test fixes and fixes pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
colin99d committed Oct 21, 2022
1 parent 8fe6df0 commit d26137c
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 70 deletions.
27 changes: 18 additions & 9 deletions openbb_terminal/dashboards/dashboards_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,47 +66,56 @@ def print_help(self):
console.print(text=mt.menu_text, menu="Dashboards")

@log_start_end(log=logger)
def call_stocks(self, other_args: List[str]):
@staticmethod
def call_stocks(other_args: List[str]):
"""Process stocks command"""
create_call_voila(other_args, "stocks", "stocks")

@log_start_end(log=logger)
def call_correlation(self, other_args: List[str]):
@staticmethod
def call_correlation(other_args: List[str]):
"""Process correlation command"""
create_call_voila(other_args, "correlation", "correlation")

@log_start_end(log=logger)
def call_vsurf(self, other_args: List[str]):
@staticmethod
def call_vsurf(other_args: List[str]):
"""Process vsurf command"""
create_call_voila(other_args, "vsurf", "")

@log_start_end(log=logger)
def call_chains(self, other_args: List[str]):
@staticmethod
def call_chains(other_args: List[str]):
"""Process chains command"""
create_call_voila(other_args, "chains", "")

@log_start_end(log=logger)
def call_shortdata(self, other_args: List[str]):
@staticmethod
def call_shortdata(other_args: List[str]):
"""Process shortdata command"""
create_call_voila(other_args, "shortdata", "")

@log_start_end(log=logger)
def call_crypto(self, other_args: List[str]):
@staticmethod
def call_crypto(other_args: List[str]):
"""Process crypto command"""
create_call_voila(other_args, "crypto", "")

@log_start_end(log=logger)
def call_futures(self, other_args: List[str]):
@staticmethod
def call_futures(other_args: List[str]):
"""Process futures command"""
create_call_voila(other_args, "futures", "")

@log_start_end(log=logger)
def call_forecast(self, other_args: List[str]):
@staticmethod
def call_forecast(other_args: List[str]):
"""Process forecast command"""
create_call_voila(other_args, "forecast", "")

@log_start_end(log=logger)
def call_forecasting(self, other_args: List[str]):
@staticmethod
def call_forecasting(other_args: List[str]):
"""Process forecasting command"""
create_call_streamlit(other_args, "forecast")

Expand Down
5 changes: 3 additions & 2 deletions openbb_terminal/dashboards/stream/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def __init__(self):
self.feature_target = None

# pylint: disable=R0913
@staticmethod
def handle_changes(
self,
past_covariates: list[str],
start,
end,
Expand Down Expand Up @@ -193,7 +193,8 @@ def handle_eng(self, target, feature):
self.feature_target = target
self.feature_model = feat_engs[feature]

def on_ticker_change(self):
@staticmethod
def on_ticker_change():
tickers = st.session_state.ticker
if tickers:
interval = st.session_state.interval
Expand Down
2 changes: 0 additions & 2 deletions openbb_terminal/economy/investingcom_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

COLORS = ["rgb", "binary", "openbb"]

# pylint: disable=unnecessary-lambda-assignment


@log_start_end(log=logger)
def display_spread_matrix(
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/economy/nasdaq_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_economic_calendar(


@log_start_end(log=logger)
def check_country_code_type(list_of_codes: str) -> list[str]:
def check_country_code_type(list_of_codes: str) -> List[str]:
"""Check that codes are valid for NASDAQ API"""
nasdaq_codes = list(
pd.read_csv(os.path.join(os.path.dirname(__file__), "NASDAQ_CountryCodes.csv"))[
Expand Down
48 changes: 32 additions & 16 deletions openbb_terminal/featflags_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def print_help(self):

console.print(text=mt.menu_text, menu="Feature Flags")

def call_retryload(self, _):
@staticmethod
def call_retryload(_):
"""Process retryload command"""
obbff.RETRY_WITH_LOAD = not obbff.RETRY_WITH_LOAD
set_key(
Expand All @@ -84,7 +85,8 @@ def call_retryload(self, _):
console.print("")

@log_start_end(log=logger)
def call_tab(self, _):
@staticmethod
def call_tab(_):
"""Process tab command"""
obbff.USE_TABULATE_DF = not obbff.USE_TABULATE_DF
set_key(
Expand All @@ -93,7 +95,8 @@ def call_tab(self, _):
console.print("")

@log_start_end(log=logger)
def call_cls(self, _):
@staticmethod
def call_cls(_):
"""Process cls command"""
obbff.USE_CLEAR_AFTER_CMD = not obbff.USE_CLEAR_AFTER_CMD
set_key(
Expand All @@ -104,14 +107,16 @@ def call_cls(self, _):
console.print("")

@log_start_end(log=logger)
def call_color(self, _):
@staticmethod
def call_color(_):
"""Process color command"""
obbff.USE_COLOR = not obbff.USE_COLOR
set_key(obbff.USER_ENV_FILE, "OPENBB_USE_COLOR", str(obbff.USE_COLOR))
console.print("")

@log_start_end(log=logger)
def call_promptkit(self, _):
@staticmethod
def call_promptkit(_):
"""Process promptkit command"""
obbff.USE_PROMPT_TOOLKIT = not obbff.USE_PROMPT_TOOLKIT
set_key(
Expand All @@ -122,7 +127,8 @@ def call_promptkit(self, _):
console.print("")

@log_start_end(log=logger)
def call_thoughts(self, _):
@staticmethod
def call_thoughts(_):
"""Process thoughts command"""
obbff.ENABLE_THOUGHTS_DAY = not obbff.ENABLE_THOUGHTS_DAY
set_key(
Expand All @@ -133,7 +139,8 @@ def call_thoughts(self, _):
console.print("")

@log_start_end(log=logger)
def call_reporthtml(self, _):
@staticmethod
def call_reporthtml(_):
"""Process reporthtml command"""
obbff.OPEN_REPORT_AS_HTML = not obbff.OPEN_REPORT_AS_HTML
set_key(
Expand All @@ -144,7 +151,8 @@ def call_reporthtml(self, _):
console.print("")

@log_start_end(log=logger)
def call_exithelp(self, _):
@staticmethod
def call_exithelp(_):
"""Process exithelp command"""
obbff.ENABLE_EXIT_AUTO_HELP = not obbff.ENABLE_EXIT_AUTO_HELP
set_key(
Expand All @@ -155,7 +163,8 @@ def call_exithelp(self, _):
console.print("")

@log_start_end(log=logger)
def call_rcontext(self, _):
@staticmethod
def call_rcontext(_):
"""Process rcontext command"""
obbff.REMEMBER_CONTEXTS = not obbff.REMEMBER_CONTEXTS
set_key(
Expand All @@ -166,21 +175,24 @@ def call_rcontext(self, _):
console.print("")

@log_start_end(log=logger)
def call_dt(self, _):
@staticmethod
def call_dt(_):
"""Process dt command"""
obbff.USE_DATETIME = not obbff.USE_DATETIME
set_key(obbff.USER_ENV_FILE, "OPENBB_USE_DATETIME", str(obbff.USE_DATETIME))
console.print("")

@log_start_end(log=logger)
def call_rich(self, _):
@staticmethod
def call_rich(_):
"""Process rich command"""
obbff.ENABLE_RICH = not obbff.ENABLE_RICH
set_key(obbff.USER_ENV_FILE, "OPENBB_ENABLE_RICH", str(obbff.ENABLE_RICH))
console.print("")

@log_start_end(log=logger)
def call_richpanel(self, _):
@staticmethod
def call_richpanel(_):
"""Process richpanel command"""
obbff.ENABLE_RICH_PANEL = not obbff.ENABLE_RICH_PANEL
set_key(
Expand All @@ -191,21 +203,24 @@ def call_richpanel(self, _):
console.print("")

@log_start_end(log=logger)
def call_ion(self, _):
@staticmethod
def call_ion(_):
"""Process ion command"""
obbff.USE_ION = not obbff.USE_ION
set_key(obbff.USER_ENV_FILE, "OPENBB_USE_ION", str(obbff.USE_ION))
console.print("")

@log_start_end(log=logger)
def call_watermark(self, _):
@staticmethod
def call_watermark(_):
"""Process watermark command"""
obbff.USE_WATERMARK = not obbff.USE_WATERMARK
set_key(obbff.USER_ENV_FILE, "OPENBB_USE_WATERMARK", str(obbff.USE_WATERMARK))
console.print("")

@log_start_end(log=logger)
def call_cmdloc(self, _):
@staticmethod
def call_cmdloc(_):
"""Process cmdloc command"""
obbff.USE_CMD_LOCATION_FIGURE = not obbff.USE_CMD_LOCATION_FIGURE
set_key(
Expand All @@ -216,7 +231,8 @@ def call_cmdloc(self, _):
console.print("")

@log_start_end(log=logger)
def call_tbhint(self, _):
@staticmethod
def call_tbhint(_):
"""Process tbhint command"""
if obbff.TOOLBAR_HINT:
console.print("Will take effect when running terminal next.")
Expand Down
18 changes: 8 additions & 10 deletions openbb_terminal/helper_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def __init__(

self.applyMPLstyle()

def load_custom_fonts_from_folder(self, folder: Path) -> None:
@staticmethod
def load_custom_fonts_from_folder(folder: Path) -> None:
"""Load custom fonts form folder.
TTF and OTF fonts are loaded into the mpl font manager and are available for
Expand Down Expand Up @@ -306,7 +307,8 @@ def style_primary_axis(
ax.xaxis.set_major_locator(ticker.MaxNLocator(6, integer=True))
ax.tick_params(axis="x", labelrotation=self.xticks_rotation)

def style_twin_axis(self, ax: plt.Axes):
@staticmethod
def style_twin_axis(ax: plt.Axes):
"""Apply styling to a twin axis.
Parameters
Expand All @@ -333,10 +335,8 @@ def style_twin_axes(self, ax1: plt.Axes, ax2: plt.Axes):

ax2.grid(visible=False)

def add_label(
self,
fig: plt.figure,
):
@staticmethod
def add_label(fig: plt.figure):
"""Add a text label to a figure in a funny position.
Parameters
Expand All @@ -356,10 +356,8 @@ def add_label(
)

# pylint: disable=import-outside-toplevel
def add_cmd_source(
self,
fig: plt.figure,
):
@staticmethod
def add_cmd_source(fig: plt.figure):
"""Add a text label to a figure in a funny position.
Parameters
Expand Down
18 changes: 12 additions & 6 deletions openbb_terminal/parent_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ def switch(self, an_input: str) -> List[str]:
return self.queue

@log_start_end(log=logger)
def call_cls(self, _) -> None:
@staticmethod
def call_cls(_) -> None:
"""Process cls command"""
system_clear()

Expand Down Expand Up @@ -491,7 +492,8 @@ def call_support(self, other_args: List[str]) -> None:
)

@log_start_end(log=logger)
def call_glossary(self, other_args: List[str]) -> None:
@staticmethod
def call_glossary(other_args: List[str]) -> None:
"""Process glossary command"""
parser = argparse.ArgumentParser(
add_help=False,
Expand Down Expand Up @@ -527,7 +529,8 @@ def call_glossary(self, other_args: List[str]) -> None:
console.print("Word is not in the glossary.\n")

@log_start_end(log=logger)
def call_wiki(self, other_args: List[str]) -> None:
@staticmethod
def call_wiki(other_args: List[str]) -> None:
"""Process wiki command"""
parser = argparse.ArgumentParser(
add_help=False,
Expand Down Expand Up @@ -556,7 +559,8 @@ def call_wiki(self, other_args: List[str]) -> None:
search_wikipedia(expression)

@log_start_end(log=logger)
def call_record(self, other_args) -> None:
@staticmethod
def call_record(other_args) -> None:
"""Process record command"""
parser = argparse.ArgumentParser(
add_help=False,
Expand Down Expand Up @@ -592,7 +596,8 @@ def call_record(self, other_args) -> None:
RECORD_SESSION = True

@log_start_end(log=logger)
def call_stop(self, _) -> None:
@staticmethod
def call_stop(_) -> None:
"""Process stop command"""
global RECORD_SESSION
global SESSION_RECORDED
Expand Down Expand Up @@ -628,7 +633,8 @@ def call_stop(self, _) -> None:
SESSION_RECORDED = list()

@log_start_end(log=logger)
def call_screenshot(self, other_args: List[str]) -> None:
@staticmethod
def call_screenshot(other_args: List[str]) -> None:
"""Process screenshot command"""
parser = argparse.ArgumentParser(
add_help=False,
Expand Down
5 changes: 3 additions & 2 deletions openbb_terminal/portfolio/brokers/degiro/degiro_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def __init__(self):
self.__default_credentials = self.get_default_credentials()
self.__trading_api = self.get_default_trading_api()

def get_default_credentials(self):
@staticmethod
def get_default_credentials():
"""
Generate default credentials object from config file
Expand Down Expand Up @@ -251,8 +252,8 @@ def create_calculate_product_id(
return product

@log_start_end(log=logger)
@staticmethod
def create_calculate_size(
self,
price: float,
size: int,
up_to: float,
Expand Down
3 changes: 2 additions & 1 deletion openbb_terminal/portfolio/portfolio_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ def calculate_value(self):
self.historical_trade_data = trade_data

@log_start_end(log=logger)
def calculate_reserves(self):
@staticmethod
def calculate_reserves():
"""Takes dividends into account for returns calculation"""
# TODO: Add back cash dividends and deduct exchange costs
console.print("Still has to be build.")
Expand Down
Loading

0 comments on commit d26137c

Please sign in to comment.