GitHub Actions: make pyupgrade mandatory and max-line-length=122

This commit is contained in:
Christian Clauss
2021-03-06 21:04:09 +01:00
parent 97bb344eec
commit 9f550ff9af
8 changed files with 20 additions and 14 deletions

View File

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

View File

@@ -28,7 +28,7 @@ def buy_sell_ratio_color_red_green(val: str) -> str:
Fore.GREEN, buys, Style.RESET_ALL, sells
)
return "{}% Buys, {}{}%{} Sells".format(buys, Fore.RED, sells, Style.RESET_ALL)
return f"{buys}% Buys, {Fore.RED}{sells}%{Style.RESET_ALL} Sells"
def price_change_color_red_green(val: str) -> str:

View File

@@ -117,7 +117,7 @@ def sean_seah_warnings(l_args, s_ticker):
with open(filepath) as fp:
line = fp.readline()
while line:
print("{}".format(line.strip()))
print(f"{line.strip()}")
line = fp.readline()
print("")

View File

@@ -375,7 +375,10 @@ def earnings(l_args, s_ticker):
pd.options.display.max_colwidth = 40
# Request EARNINGS data from Alpha Vantage API
s_req = f"https://www.alphavantage.co/query?function=EARNINGS&symbol={s_ticker}&apikey={cfg.API_KEY_FINANCIALMODELINGPREP}"
s_req = (
"https://www.alphavantage.co/query?function=EARNINGS&"
f"symbol={s_ticker}&apikey={cfg.API_KEY_FINANCIALMODELINGPREP}"
)
result = requests.get(s_req, stream=True)
# If the returned data was successful

View File

@@ -225,7 +225,7 @@ def sustainability(l_args, s_ticker):
return
# ---------------------------------------------------- CALENDAR_EARNINGS ----------------------------------------------------
# ---------------------------------------------------- CALENDAR_EARNINGS ------------------------------------------------
def calendar_earnings(l_args, s_ticker):
parser = argparse.ArgumentParser(
prog="calendar_earnings",

View File

@@ -83,7 +83,7 @@ def long_number_format(num) -> str:
if num.is_integer():
return "%d%s" % (num, ["", " K", " M", " B", " T", " P"][magnitude])
return "%.3f%s" % (num, ["", " K", " M", " B", " T", " P"][magnitude])
return "{:.3f}{}".format(num, ["", " K", " M", " B", " T", " P"][magnitude])
if isinstance(num, int):
num = str(num)
if num.lstrip("-").isdigit():
@@ -96,7 +96,7 @@ def long_number_format(num) -> str:
if num.is_integer():
return "%d%s" % (num, ["", " K", " M", " B", " T", " P"][magnitude])
return "%.3f%s" % (num, ["", " K", " M", " B", " T", " P"][magnitude])
return "{:.3f}{}".format(num, ["", " K", " M", " B", " T", " P"][magnitude])
return num
@@ -176,7 +176,7 @@ def get_data(tweet):
def clean_tweet(tweet: str, s_ticker: str) -> str:
whitespace = re.compile(r"\s+")
web_address = re.compile(r"(?i)http(s):\/\/[a-z0-9.~_\-\/]+")
ticker = re.compile(r"(?i)@{}(?=\b)".format(s_ticker))
ticker = re.compile(fr"(?i)@{s_ticker}(?=\b)")
user = re.compile(r"(?i)@[a-z0-9_]+")
tweet = whitespace.sub(" ", tweet)

View File

@@ -114,7 +114,7 @@ def sen_menu(s_ticker, s_start):
elif ns_known_args.cmd == "popular":
reddit_api.popular_tickers(l_args)
# ---------------------------------------------------- STOCKTWITS ---------------------------------------------------
# ---------------------------------------------------- STOCKTWITS -----------------------------------------------
elif ns_known_args.cmd == "bullbear":
stocktwits_api.bullbear(l_args, s_ticker)
@@ -127,7 +127,7 @@ def sen_menu(s_ticker, s_start):
elif ns_known_args.cmd == "stalker":
stocktwits_api.stalker(l_args)
# ----------------------------------------------------- TWITTER ---------------------------------------------------
# ----------------------------------------------------- TWITTER -------------------------------------------------
elif ns_known_args.cmd == "infer":
twitter_api.inference(l_args, s_ticker)

View File

@@ -154,7 +154,10 @@ def view(l_args, s_ticker, s_start, s_interval, df_stock):
dest="n_type",
type=check_positive,
default=5, # in case it's daily
help="1234 corresponds to types: 1. open; 2. high; 3.low; 4. close; while 14 corresponds to types: 1.open; 4. close",
help=(
"1234 corresponds to types: 1. open; 2. high; 3. low; 4. close; "
"while 14 corresponds to types: 1. open; 4. close"
),
)
try:
@@ -228,7 +231,7 @@ def view(l_args, s_ticker, s_start, s_interval, df_stock):
plot_view_stock(df_stock.iloc[:, ln_col_idx], ns_parser.s_ticker)
# ----------------------------------------------------- HELP ------------------------------------------------------------------
# ----------------------------------------------------- HELP ------------------------------------------------------------
def print_help(s_ticker, s_start, s_interval, b_is_market_open):
"""Print help"""
print("What do you want to do?")