Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves the settings/userdata command, and upgrade ruff #5359

Merged
merged 22 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion generate_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ def build(self) -> None:
f.write(content.replace(b"\r", b"\n"))

# We run black to make sure the code is formatted correctly
subprocess.check_call(["black", "openbb_terminal"]) # nosec: B603, B607
subprocess.check_call( # noqa: S603 # nosec: B603, B607
["black", "openbb_terminal"] # noqa: S603,S607
)


def generate_sdk(sort: bool = False) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/account/show_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ def set_show_prompt(value: bool):
value : bool
The show_prompt flag.
"""
global __show_prompt # pylint: disable=global-statement
global __show_prompt # pylint: disable=global-statement # noqa: PLW0603
__show_prompt = value
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def validate(
) -> None:
"""Validate tickers."""
valids = []
with urllib.request.urlopen(url) as file:
with urllib.request.urlopen(url) as file: # noqa: S310
for line in file:
new_item = line.decode("utf-8").replace("\n", "").strip()
valids.append(new_item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ def close(self):
log_sender.send_path(path=closed_log_path, last=True)
try:
log_sender.join(timeout=3)
except Exception:
pass # noqa
except Exception: # noqa: S110
pass

super().close()

Expand Down
4 changes: 1 addition & 3 deletions openbb_terminal/core/models/preferences_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
from pydantic import NonNegativeInt, PositiveFloat, PositiveInt
from pydantic.dataclasses import dataclass

from openbb_terminal.core.config.paths import (
HOME_DIRECTORY,
)
from openbb_terminal.core.config.paths import HOME_DIRECTORY
from openbb_terminal.core.models import BaseModel

# pylint: disable=too-many-instance-attributes, disable=no-member, useless-parent-delegation
Expand Down
23 changes: 12 additions & 11 deletions openbb_terminal/core/plots/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,12 @@ async def process_image(self, export_image: Path):

if get_current_user().preferences.PLOT_OPEN_EXPORT:
if sys.platform == "win32":
os.startfile(export_image) # nosec: B606
os.startfile(export_image) # noqa: S606 # nosec: B606
else:
opener = "open" if sys.platform == "darwin" else "xdg-open"
subprocess.check_call([opener, export_image]) # nosec: B603
subprocess.check_call(
[opener, export_image] # nosec: B603 # noqa: S603
) # nosec: B603 # noqa: S603

def send_table(
self,
Expand Down Expand Up @@ -422,7 +424,7 @@ async def get_results(self, description: str) -> dict:
data: dict = self.recv.get(block=False) or {}
if data.get("result", False):
return json.loads(data["result"])
except Exception: # pylint: disable=W0703
except Exception: # pylint: disable=W0703 # noqa: S110
pass

await asyncio.sleep(1)
Expand Down Expand Up @@ -480,14 +482,13 @@ async def download_plotly_js():
# this is so we don't have to block the main thread
async with aiohttp.ClientSession(
connector=aiohttp.TCPConnector(verify_ssl=False)
) as session:
async with session.get(f"https://cdn.plot.ly/{js_filename}") as resp:
with open(str(PLOTLYJS_PATH), "wb") as f:
while True:
chunk = await resp.content.read(1024)
if not chunk:
break
f.write(chunk)
) as session, session.get(f"https://cdn.plot.ly/{js_filename}") as resp:
with open(str(PLOTLYJS_PATH), "wb") as f:
while True:
chunk = await resp.content.read(1024)
if not chunk:
break
f.write(chunk)

# We delete the old version of plotly.js
for file in (PLOTS_CORE_PATH / "assets").glob("plotly*.js"):
Expand Down
6 changes: 4 additions & 2 deletions openbb_terminal/core/plots/plotly_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,9 @@ def _validate_x(data: Union[np.ndarray, pd.Series, type[TimeSeriesT]]):
max_y = 0
for i0, (x_i, name_i, color_i) in enumerate(zip(valid_x, name, colors)):
if not color_i:
color_i = theme.up_color if i0 % 2 == 0 else theme.down_color
color_i = ( # noqa: PLW2901
theme.up_color if i0 % 2 == 0 else theme.down_color
)

res_mean, res_std = np.mean(x_i), np.std(x_i)
res_min, res_max = min(x_i), max(x_i)
Expand Down Expand Up @@ -1054,7 +1056,7 @@ def add_legend_label(
[trace, trace_.mode, trace_.marker, trace_.line_dash],
):
if not arg and default:
arg = default
arg = default # noqa: PLW2901

kwargs.update(dict(yaxis=trace_.yaxis))
break
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/core/plots/plotly_ta/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __new__(mcs: Type["PluginMeta"], *args: Any, **kwargs: Any) -> "PluginMeta":

is_static_method = isinstance(value, staticmethod)
if is_static_method:
value = value.__func__
value = value.__func__ # noqa: PLW2901
if isinstance(value, Indicator):
if is_static_method:
raise TypeError(
Expand Down
Loading
Loading