Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone committed Dec 11, 2024
1 parent 0834fc4 commit c465374
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async def setup_database(results_path, table_name):
"Unexpected error caused by an invalid SQLite database file."
"Please check the path, and inspect the file if it exists."
+ f" -> {e}"
)
) from e
async with aiosqlite.connect(results_path) as conn:
await conn.execute(
f"""
Expand All @@ -195,7 +195,6 @@ async def setup_database(results_path, table_name):
async def write_to_db(message, results_path, table_name, limit):
"""Write the WebSocket message to the SQLite database."""
# pylint: disable=import-outside-toplevel
import json # noqa
import aiosqlite

conn = await aiosqlite.connect(results_path)
Expand Down Expand Up @@ -238,6 +237,11 @@ async def write_to_db(message, results_path, table_name, limit):
)

await conn.commit()
except Exception as e: # pylint: disable=broad-except
raise OpenBBError(
f"Unexpected error encountered while inserting message into the database. -> {e.__class__.__name__}: {e}"
) from e

finally:
await conn.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def _validate_conditions(cls, values):
new_conditions = []
conditions = conditions.replace(" ", "")

for char in range(len(conditions)):
for char in range(
len(conditions)
): # pylint: disable=consider-using-enumerate
if trade_type == "trade":
new_conditions.append(
TRADE_CONDITIONS.get(conditions[char], conditions[char])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ def _validate_conditions(cls, v):
"""Validate the conditions."""
if v is None or isinstance(v, list) and v[0] == 0:
return None
elif isinstance(v, list) and v[0] == 1:
if isinstance(v, list) and v[0] == 1:
return "sellside"
elif isinstance(v, list) and v[0] == 2:
if isinstance(v, list) and v[0] == 2:
return "buyside"
return str(v)

Expand Down Expand Up @@ -1200,7 +1200,7 @@ def __new__(cls, **data):
or MODEL_MAP.get(data.get("type", ""))
)
if not model:
return super().__new__(cls)
return super().__new__(cls) # pylint: disable=E1120

return model.model_validate(data) # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ async def connect_and_stream():
logger.error("PROVIDER ERROR: WebSocket connection closed")

except Exception as e: # pylint: disable=broad-except
msg = f"PROVIDER ERROR: {e.__class__.__name__} -> {e}"
logger.error(msg)
ERR = f"PROVIDER ERROR: {e.__class__.__name__} -> {e}"
logger.error(ERR)

finally:
loop.stop()
sys.exit(0)

0 comments on commit c465374

Please sign in to comment.