GitHub Actions: Make mypy a mandatory test

This commit is contained in:
Christian Clauss
2021-03-06 12:38:17 +01:00
parent bf1a2a5c33
commit 7c9f39ec0c
3 changed files with 12 additions and 17 deletions

View File

@@ -25,7 +25,7 @@ jobs:
- run: black --check .
- run: codespell --ignore-words-list="mape" --quiet-level=2 --skip=".git" # --skip=""
- run: flake8 . --count --ignore=E203,E302,F401,F841,W503 --max-line-length=140 --show-source --statistics
- run: mypy --ignore-missing-imports . || true
- run: mypy --ignore-missing-imports .
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
- run: safety check
- run: pylint **/*.py

View File

@@ -161,34 +161,29 @@ def long_number_format(num) -> str:
def clean_data_values_to_float(val: str) -> float:
# Remove parenthesis if they exist
if val.startswith("("):
val = val[1:]
if val.endswith(")"):
val = val[:-1]
# Remove any leading or trailing parentheses and spaces
val = val.strip("( )")
if val == "-":
val = "0"
# Convert percentage to decimal
if val.endswith("%"):
val = float(val[:-1]) / 100.0
val_as_float = float(val[:-1]) / 100.0
# Convert from billions
elif val.endswith("B"):
val = float(val[:-1]) * 1_000_000_000
val_as_float = float(val[:-1]) * 1_000_000_000
# Convert from millions
elif val.endswith("M"):
val = float(val[:-1]) * 1_000_000
val_as_float = float(val[:-1]) * 1_000_000
# Convert from thousands
elif val.endswith("K"):
val = float(val[:-1]) * 1000
val_as_float = float(val[:-1]) * 1000
else:
val = float(val)
return val
val_as_float = float(val)
return val_as_float
def int_or_round_float(x):
def int_or_round_float(x) -> str:
if (x - int(x) < -sys.float_info.epsilon) or (x - int(x) > sys.float_info.epsilon):
return " " + str(round(x, 2))
@@ -221,7 +216,7 @@ def get_next_stock_market_days(last_stock_day, n_next_days) -> list:
return l_pred_days
def get_data(tweet) -> hash:
def get_data(tweet):
if "+" in tweet["created_at"]:
s_datetime = tweet["created_at"].split(" +")[0]
else:

View File

@@ -23,7 +23,7 @@ def load_tweets(s_ticker: str, count: int) -> DataFrame:
# Request Twitter API
response = requests.get(
"https://api.twitter.com/1.1/search/tweets.json",
params=params,
params=params, # type: ignore
headers={"authorization": "Bearer " + cfg.API_TWITTER_BEARER_TOKEN},
)