mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-27 11:41:32 +00:00
linting
This commit is contained in:
@@ -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"""
|
||||
@@ -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)
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -129,7 +129,9 @@ class IntrinioWebSocketData(WebSocketData):
|
||||
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])
|
||||
|
||||
@@ -353,9 +353,9 @@ class PolygonCryptoTradeWebSocketData(WebSocketData):
|
||||
"""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)
|
||||
|
||||
@@ -1200,7 +1200,7 @@ class PolygonWebSocketData(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
|
||||
|
||||
|
||||
@@ -294,8 +294,9 @@ if __name__ == "__main__":
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user