mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Enabling f-string enforcement and fixing offenders (#977)
This commit is contained in:
2
.pylintrc
vendored
2
.pylintrc
vendored
@@ -54,7 +54,7 @@ confidence=
|
||||
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
|
||||
# disable=too-many-instance-attributes,len-as-condition,too-few-public-methods,anomalous-backslash-in-string,no-else-return,simplifiable-if-statement,too-many-arguments,duplicate-code,no-name-in-module,no-member,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,missing-docstring,invalid-name,bad-whitespace,consider-using-enumerate,unexpected-keyword-arg
|
||||
|
||||
disable=useless-return,missing-docstring,invalid-name,import-error,bad-continuation,broad-except,unnecessary-lambda,no-self-use,duplicate-code,consider-using-generator,unbalanced-tuple-unpacking,use-list-literal,no-name-in-module,use-sequence-for-iteration,use-dict-literal,unspecified-encoding,unsubscriptable-object,consider-using-f-string
|
||||
disable=useless-return,missing-docstring,invalid-name,import-error,bad-continuation,broad-except,unnecessary-lambda,no-self-use,duplicate-code,consider-using-generator,unbalanced-tuple-unpacking,use-list-literal,no-name-in-module,use-sequence-for-iteration,use-dict-literal,unspecified-encoding,unsubscriptable-object
|
||||
|
||||
# Enable the message, report, category or checker with the given id(s). You can
|
||||
# either give multiple identifier separated by comma (,) or put this option
|
||||
|
||||
@@ -375,12 +375,13 @@ def display_seasonal(
|
||||
print("Time-Series Level is " + str(round(data.mean(), 2)))
|
||||
|
||||
Ft = max(0, 1 - np.var(result.resid)) / np.var(result.trend + result.resid)
|
||||
print("Strength of Trend: %.4f" % Ft)
|
||||
print(f"Strength of Trend: {Ft:.4f}")
|
||||
|
||||
Fs = max(
|
||||
0,
|
||||
1 - np.var(result.resid) / np.var(result.seasonal + result.resid),
|
||||
)
|
||||
print("Strength of Seasonality: %.4f" % Fs, "\n")
|
||||
print(f"Strength of Seasonality: {Fs:.4f}\n")
|
||||
|
||||
export_data(
|
||||
export,
|
||||
|
||||
@@ -54,7 +54,7 @@ class CoinbaseRequestException(Exception):
|
||||
self.message = message
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "CoinbaseRequestException: %s" % self.message
|
||||
return f"CoinbaseRequestException: {self.message}"
|
||||
|
||||
|
||||
class CoinbaseApiException(Exception):
|
||||
@@ -65,7 +65,7 @@ class CoinbaseApiException(Exception):
|
||||
self.message = message
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "CoinbaseApiException: %s" % self.message
|
||||
return f"CoinbaseApiException: {self.message}"
|
||||
|
||||
|
||||
def check_validity_of_product(product_id: str) -> str:
|
||||
@@ -117,11 +117,11 @@ def make_coinbase_request(
|
||||
response = requests.get(url + endpoint, params=params, auth=auth)
|
||||
|
||||
if not 200 <= response.status_code < 300:
|
||||
raise CoinbaseApiException("Invalid Authentication: %s" % response.text)
|
||||
raise CoinbaseApiException(f"Invalid Authentication: {response.text}")
|
||||
try:
|
||||
return response.json()
|
||||
except ValueError as e:
|
||||
raise CoinbaseRequestException("Invalid Response: %s" % response.text) from e
|
||||
raise CoinbaseRequestException(f"Invalid Response: {response.text}") from e
|
||||
|
||||
|
||||
def _get_account_coin_dict() -> dict:
|
||||
|
||||
@@ -113,8 +113,8 @@ def very_long_number_formatter(num: Union[str, int, float]) -> str:
|
||||
magnitude += 1
|
||||
num /= 1000.0
|
||||
num = round(num, 1)
|
||||
return "{}{}".format(
|
||||
f"{num:f}".rstrip("0").rstrip("."),
|
||||
["", "K", "M", "B", "T"][magnitude],
|
||||
)
|
||||
formatted_num = f"{num:f}".rstrip("0").rstrip(".")
|
||||
|
||||
return f'{formatted_num}{["", "K", "M", "B", "T"][magnitude]}'
|
||||
|
||||
return num
|
||||
|
||||
@@ -17,7 +17,7 @@ class ApiKeyException(Exception):
|
||||
self.message = message
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "ApiKeyException: %s" % self.message
|
||||
return f"ApiKeyException: {self.message}"
|
||||
|
||||
|
||||
def make_request(params: Optional[dict] = None) -> dict:
|
||||
@@ -39,11 +39,11 @@ def make_request(params: Optional[dict] = None) -> dict:
|
||||
response = requests.get(url, params=params)
|
||||
|
||||
if not 200 <= response.status_code < 300:
|
||||
raise ApiKeyException("Invalid Authentication: %s" % response.text)
|
||||
raise ApiKeyException(f"Invalid Authentication: {response.text}")
|
||||
try:
|
||||
return response.json()
|
||||
except Exception as e:
|
||||
raise ValueError("Invalid Response: %s" % response.text) from e
|
||||
raise ValueError(f"Invalid Response: {response.text}") from e
|
||||
|
||||
|
||||
def get_whales_transactions(min_value: int = 800000, limit: int = 100) -> pd.DataFrame:
|
||||
|
||||
@@ -20,7 +20,7 @@ class ApiKeyException(Exception):
|
||||
self.message = message
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "ApiKeyException: %s" % self.message
|
||||
return f"ApiKeyException: {self.message}"
|
||||
|
||||
|
||||
def make_request(**kwargs: Any) -> dict:
|
||||
@@ -65,12 +65,12 @@ def make_request(**kwargs: Any) -> dict:
|
||||
response = requests.get(url)
|
||||
|
||||
if not 200 <= response.status_code < 300:
|
||||
raise ApiKeyException("Invalid Authentication: %s" % response.text)
|
||||
raise ApiKeyException(f"Invalid Authentication: {response.text}")
|
||||
|
||||
try:
|
||||
return response.json()
|
||||
except Exception as e:
|
||||
raise ValueError("Invalid Response: %s" % response.text) from e
|
||||
raise ValueError(f"Invalid Response: {response.text}") from e
|
||||
|
||||
|
||||
def _parse_post(post: dict) -> dict:
|
||||
|
||||
@@ -119,11 +119,7 @@ def plot_overall_return(
|
||||
ax.axhline(0, ls="--", lw=1, color="black", zorder=2)
|
||||
fig.set_facecolor("white")
|
||||
ax.set_title(
|
||||
"%s - %s"
|
||||
% (
|
||||
comb.index[:1][0].strftime("%Y/%m/%d"),
|
||||
comb.index[-1:][0].strftime("%Y/%m/%d"),
|
||||
),
|
||||
f'{comb.index[:1][0].strftime("%Y/%m/%d")} - {comb.index[-1:][0].strftime("%Y/%m/%d")}',
|
||||
fontsize=12,
|
||||
color="gray",
|
||||
)
|
||||
@@ -178,9 +174,7 @@ def plot_rolling_beta(df: pd.DataFrame) -> ImageReader:
|
||||
ax.axhline(0, ls="--", lw=1, color="black", zorder=2)
|
||||
fig.set_facecolor("white")
|
||||
ax.set_title(
|
||||
"%s - %s"
|
||||
% (df.index[:1][0].strftime("%Y-%m-%d"), df.index[-1:][0].strftime("%Y-%m-%d")),
|
||||
fontsize=12,
|
||||
f'{df.index[:1][0].strftime("%Y-%m-%d")} - {df.index[-1:][0].strftime("%Y-%m-%d")}',
|
||||
color="gray",
|
||||
)
|
||||
ax.set_facecolor("white")
|
||||
|
||||
@@ -77,26 +77,28 @@ def get_fails_to_deliver(
|
||||
|
||||
for y in range(start.year, end.year + 1):
|
||||
if y < end.year:
|
||||
for m in range(start.month, 13):
|
||||
month = "%02d" % m
|
||||
if m == start.month and y == start.year:
|
||||
for a_month in range(start.month, 13):
|
||||
formatted_month = f"{a_month:02d}"
|
||||
|
||||
if a_month == start.month and y == start.year:
|
||||
if start.day < 16:
|
||||
ftd_dates.append(str(y) + month + "a")
|
||||
ftd_dates.append(str(y) + month + "b")
|
||||
ftd_dates.append(str(y) + formatted_month + "a")
|
||||
ftd_dates.append(str(y) + formatted_month + "b")
|
||||
else:
|
||||
ftd_dates.append(str(y) + month + "a")
|
||||
ftd_dates.append(str(y) + month + "b")
|
||||
ftd_dates.append(str(y) + formatted_month + "a")
|
||||
ftd_dates.append(str(y) + formatted_month + "b")
|
||||
|
||||
else:
|
||||
for m in range(1, end.month):
|
||||
month = "%02d" % m
|
||||
if m == end.month - 1:
|
||||
ftd_dates.append(str(y) + month + "a")
|
||||
for a_month in range(1, end.month):
|
||||
formatted_month = f"{a_month:02d}"
|
||||
|
||||
if a_month == end.month - 1:
|
||||
ftd_dates.append(str(y) + formatted_month + "a")
|
||||
if end.day > 15:
|
||||
ftd_dates.append(str(y) + month + "b")
|
||||
ftd_dates.append(str(y) + formatted_month + "b")
|
||||
else:
|
||||
ftd_dates.append(str(y) + month + "a")
|
||||
ftd_dates.append(str(y) + month + "b")
|
||||
ftd_dates.append(str(y) + formatted_month + "a")
|
||||
ftd_dates.append(str(y) + formatted_month + "b")
|
||||
|
||||
ftd_urls = [base_url + ftd_date + ".zip" for ftd_date in ftd_dates]
|
||||
|
||||
|
||||
@@ -36,9 +36,7 @@ def buy_sell_ratio_color_red_green(val: str) -> str:
|
||||
sells = int(buy_sell_match.group(2))
|
||||
|
||||
if buys >= sells:
|
||||
return "{}{}%{} Buys, {}% Sells".format(
|
||||
Fore.GREEN, buys, Style.RESET_ALL, sells
|
||||
)
|
||||
return f"{Fore.GREEN}{buys}%{Style.RESET_ALL} Buys, {sells}% Sells"
|
||||
|
||||
return f"{buys}% Buys, {Fore.RED}{sells}%{Style.RESET_ALL} Sells"
|
||||
|
||||
|
||||
@@ -733,7 +733,7 @@ def quote(other_args: List[str], s_ticker: str):
|
||||
|
||||
quote_df["Change"] = quote_df["Price"] - quote_df["Previous Close"]
|
||||
quote_df["Change %"] = quote_df.apply(
|
||||
lambda x: "{:.2f}%".format((x["Change"] / x["Previous Close"]) * 100),
|
||||
lambda x: f'{((x["Change"] / x["Previous Close"]) * 100):.2f}%',
|
||||
axis="columns",
|
||||
)
|
||||
for c in [
|
||||
|
||||
Reference in New Issue
Block a user