Skip to content

Commit

Permalink
Merge pull request #4198 from OpenBB-finance/feature/mypy10
Browse files Browse the repository at this point in the history
Bumping to mypy 1.0
  • Loading branch information
jmaslek authored Feb 16, 2023
2 parents 2130dea + 48f59b9 commit b1ced18
Show file tree
Hide file tree
Showing 281 changed files with 10,501 additions and 10,238 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
restore-keys: ${{ runner.os }}-linting-${{ hashFiles('**/poetry.lock') }}

- run: |
pip install bandit black codespell mypy==0.982 safety pylint==2.15.2 packaging==22 ruff==0.0.243
pip install bandit black codespell mypy==1.0.0 pylint==2.15.2 ruff==0.0.247
pip install types-pytz types-requests types-termcolor types-tabulate types-PyYAML types-python-dateutil types-setuptools types-six
- run: bandit -x ./tests -r . || true
- run: black --diff --check .
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ repos:
- id: check-merge-conflict
- id: detect-private-key
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.243'
rev: 'v0.0.247'
hooks:
- id: ruff
- repo: https://github.com/codespell-project/codespell
Expand Down
4 changes: 2 additions & 2 deletions openbb_terminal/account/account_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import os
from pathlib import Path
from typing import Dict, List
from typing import Dict, List, Optional

from prompt_toolkit.completion import NestedCompleter

Expand Down Expand Up @@ -43,7 +43,7 @@ class AccountController(BaseController):

PATH = "/account/"

def __init__(self, queue: List[str] = None):
def __init__(self, queue: Optional[List[str]] = None):
super().__init__(queue)
self.ROUTINE_FILES: Dict[str, Path] = {}
self.REMOTE_CHOICES: List[str] = []
Expand Down
4 changes: 2 additions & 2 deletions openbb_terminal/alternative/alt_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import argparse
import logging
from typing import List
from typing import List, Optional

from openbb_terminal import feature_flags as obbff
from openbb_terminal.alternative import hackernews_view
Expand All @@ -26,7 +26,7 @@ class AlternativeDataController(BaseController):
PATH = "/alternative/"
CHOICES_GENERATION = True

def __init__(self, queue: List[str] = None):
def __init__(self, queue: Optional[List[str]] = None):
"""Constructor"""
super().__init__(queue)

Expand Down
4 changes: 2 additions & 2 deletions openbb_terminal/alternative/covid/covid_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import argparse
import logging
import pathlib
from typing import List
from typing import List, Optional

import pandas as pd

Expand Down Expand Up @@ -33,7 +33,7 @@ class CovidController(BaseController):
PATH = "/alternative/covid/"
CHOICES_GENERATION = True

def __init__(self, queue: List[str] = None):
def __init__(self, queue: Optional[List[str]] = None):
"""Constructor"""
super().__init__(queue)

Expand Down
6 changes: 3 additions & 3 deletions openbb_terminal/alternative/covid/covid_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def display_covid_ov(
raw: bool = False,
limit: int = 10,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
plot: bool = True,
) -> None:
"""Prints table showing historical cases and deaths by country.
Expand Down Expand Up @@ -184,7 +184,7 @@ def display_covid_stat(
raw: bool = False,
limit: int = 10,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
plot: bool = True,
) -> None:
"""Prints table showing historical cases and deaths by country.
Expand Down Expand Up @@ -241,7 +241,7 @@ def display_case_slopes(
threshold: int = 10000,
ascend: bool = False,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
) -> None:
"""Prints table showing countries with the highest case slopes.
Expand Down
5 changes: 4 additions & 1 deletion openbb_terminal/alternative/hackernews_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging
import os
from typing import Optional

from openbb_terminal.alternative.hackernews_model import get_stories
from openbb_terminal.decorators import log_start_end
Expand All @@ -12,7 +13,9 @@


@log_start_end(log=logger)
def display_stories(limit: int = 10, export: str = "", sheet_name: str = None) -> None:
def display_stories(
limit: int = 10, export: str = "", sheet_name: Optional[str] = None
) -> None:
"""View top stories from HackerNews.
Parameters
----------
Expand Down
8 changes: 5 additions & 3 deletions openbb_terminal/alternative/oss/github_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
def display_star_history(
repo: str,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
) -> None:
"""Plots repo summary [Source: https://api.github.com].
Expand Down Expand Up @@ -79,7 +79,7 @@ def display_top_repos(
categories: str = "",
limit: int = 10,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
) -> None:
"""Plots repo summary [Source: https://api.github.com].
Expand Down Expand Up @@ -139,7 +139,9 @@ def display_top_repos(


@log_start_end(log=logger)
def display_repo_summary(repo: str, export: str = "", sheet_name: str = None) -> None:
def display_repo_summary(
repo: str, export: str = "", sheet_name: Optional[str] = None
) -> None:
"""Prints table showing repo summary [Source: https://api.github.com].
Parameters
Expand Down
4 changes: 2 additions & 2 deletions openbb_terminal/alternative/oss/oss_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import argparse
import logging
from typing import List
from typing import List, Optional

from openbb_terminal import feature_flags as obbff
from openbb_terminal.alternative.oss import github_view, runa_model, runa_view
Expand All @@ -29,7 +29,7 @@ class OSSController(BaseController):
PATH = "/alternative/oss/"
CHOICES_GENERATION = True

def __init__(self, queue: List[str] = None):
def __init__(self, queue: Optional[List[str]] = None):
"""Constructor"""
super().__init__(queue)

Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/alternative/oss/runa_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def display_rossindex(
show_growth: bool = True,
chart_type: str = "stars",
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
) -> None:
"""Plots list of startups from ross index [Source: https://runacap.com/]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import argparse
import logging
from datetime import datetime, timedelta
from typing import List
from typing import List, Optional

from openbb_terminal import feature_flags as obbff
from openbb_terminal.alternative.realestate import landRegistry_view
Expand Down Expand Up @@ -40,7 +40,7 @@ class RealEstateController(BaseController):
CHOICES_GENERATION = True
# FILE_PATH = os.path.join(os.path.dirname(__file__), "README.md")

def __init__(self, queue: List[str] = None):
def __init__(self, queue: Optional[List[str]] = None):
"""Construct Data."""
super().__init__(queue)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def display_sentiment_analysis(
symbol: str,
raw: bool = False,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
):
"""Plots Sentiment analysis from FinBrain. Prints table if raw is True. [Source: FinBrain]
Expand Down
5 changes: 4 additions & 1 deletion openbb_terminal/common/behavioural_analysis/finnhub_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging
import os
from typing import Optional

import pandas as pd

Expand All @@ -16,7 +17,9 @@

@log_start_end(log=logger)
@check_api_key(["API_FINNHUB_KEY"])
def display_sentiment_stats(ticker: str, export: str = "", sheet_name: str = None):
def display_sentiment_stats(
ticker: str, export: str = "", sheet_name: Optional[str] = None
):
"""
Prints Sentiment stats which displays buzz, news score, articles last week, articles weekly average,
bullish vs bearish percentages, sector average bullish percentage, and sector average news score
Expand Down
10 changes: 5 additions & 5 deletions openbb_terminal/common/behavioural_analysis/google_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def display_mentions(
symbol: str,
start_date: str = "",
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
):
"""Plots weekly bars of stock's interest over time. other users watchlist. [Source: Google].
Expand Down Expand Up @@ -97,7 +97,7 @@ def display_correlation_interest(
data: pd.DataFrame,
words: List[str],
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
):
"""Plots interest over time of words/sentences versus stock price. [Source: Google].
Expand Down Expand Up @@ -173,7 +173,7 @@ def display_regions(
symbol: str,
limit: int = 5,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
):
"""Plots bars of regions based on stock's interest. [Source: Google].
Expand Down Expand Up @@ -229,7 +229,7 @@ def display_regions(

@log_start_end(log=logger)
def display_queries(
symbol: str, limit: int = 5, export: str = "", sheet_name: str = None
symbol: str, limit: int = 5, export: str = "", sheet_name: Optional[str] = None
):
"""Prints table showing top related queries with this stock's query. [Source: Google].
Expand Down Expand Up @@ -268,7 +268,7 @@ def display_queries(

@log_start_end(log=logger)
def display_rise(
symbol: str, limit: int = 10, export: str = "", sheet_name: str = None
symbol: str, limit: int = 10, export: str = "", sheet_name: Optional[str] = None
):
"""Prints top rising related queries with this stock's query. [Source: Google].
Expand Down
4 changes: 2 additions & 2 deletions openbb_terminal/common/behavioural_analysis/reddit_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def display_popular_tickers(
post_limit: int = 50,
subreddits: str = "",
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
):
"""Prints table showing latest popular tickers. [Source: Reddit].
Expand Down Expand Up @@ -412,7 +412,7 @@ def display_redditsent(
subreddits: str = "all",
display: bool = False,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
):
"""Plots Reddit sentiment about a search term. Prints table showing if display is True.
Expand Down
4 changes: 2 additions & 2 deletions openbb_terminal/common/behavioural_analysis/twitter_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@log_start_end(log=logger)
def display_inference(
symbol: str, limit: int = 100, export: str = "", sheet_name: str = None
symbol: str, limit: int = 100, export: str = "", sheet_name: Optional[str] = None
):
"""Prints Inference sentiment from past n tweets.
Expand Down Expand Up @@ -92,7 +92,7 @@ def display_sentiment(
n_days_past: int = 2,
compare: bool = False,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
):
"""Plots sentiments from symbol
Expand Down
3 changes: 2 additions & 1 deletion openbb_terminal/common/feedparser_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging
import os
from typing import Optional

from openbb_terminal.common import feedparser_model
from openbb_terminal.decorators import log_start_end
Expand All @@ -18,7 +19,7 @@ def display_news(
sources: str = "",
limit: int = 5,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
sort: str = "published",
):
"""Plots news for a given term and source. [Source: Feedparser]
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/common/newsapi_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def display_news(
show_newest: bool = True,
sources: str = "",
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
) -> None:
"""Prints table showing news for a given term. [Source: NewsAPI]
Expand Down
14 changes: 7 additions & 7 deletions openbb_terminal/common/quantitative_analysis/qa_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def lambda_color_red(val: Any) -> str:

@log_start_end(log=logger)
def display_summary(
data: pd.DataFrame, export: str = "", sheet_name: str = None
data: pd.DataFrame, export: str = "", sheet_name: Optional[str] = None
) -> None:
"""Prints table showing summary statistics
Expand Down Expand Up @@ -164,7 +164,7 @@ def display_cdf(
target: str,
symbol: str = "",
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
):
"""Plots Cumulative Distribution Function
Expand Down Expand Up @@ -665,7 +665,7 @@ def display_seasonal(
target: str,
multiplicative: bool = False,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
) -> None:
"""Plots seasonal decomposition data
Expand Down Expand Up @@ -810,7 +810,7 @@ def display_seasonal(

@log_start_end(log=logger)
def display_normality(
data: pd.DataFrame, target: str, export: str = "", sheet_name: str = None
data: pd.DataFrame, target: str, export: str = "", sheet_name: Optional[str] = None
) -> None:
"""Prints table showing normality statistics
Expand Down Expand Up @@ -852,7 +852,7 @@ def display_unitroot(
fuller_reg: str = "c",
kpss_reg: str = "c",
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
):
"""Prints table showing unit root test calculations
Expand Down Expand Up @@ -895,7 +895,7 @@ def display_raw(
ascend: bool = False,
limit: int = 20,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
) -> None:
"""Prints table showing raw stock data
Expand Down Expand Up @@ -956,7 +956,7 @@ def display_line(
markers_lines: Optional[List[datetime]] = None,
markers_scatter: Optional[List[datetime]] = None,
export: str = "",
sheet_name: str = None,
sheet_name: Optional[str] = None,
external_axes: Optional[List[plt.Axes]] = None,
) -> None:
"""Display line plot of data
Expand Down
Loading

0 comments on commit b1ced18

Please sign in to comment.