chore(lint): make the repository ruff-clean under the strict select
Clear the deferred full-repo lint backlog so the whole tree passes the strict ruff select (E,W,F,I,B,UP,C4,SIM). Mechanical fixes dominate: import sorting, pep585/604 annotations, dropped dead imports, and whitespace. The few semantic changes are behavior-preserving: declare __all__ on the agent_utils and alpha_vantage re-export hubs; expand 'from x import *' to explicit names; use immutable tuple defaults instead of mutable list defaults; contextlib.suppress for try/except/pass; and narrow an over-broad assertRaises.
This commit is contained in:
59 files changed
+315
-293
No files matched your search
@@ -1,5 +1,23 @@
|
||||
# Import functions from specialized modules
|
||||
from .alpha_vantage_stock import get_stock
|
||||
# Aggregates the per-category Alpha Vantage implementations into one module the
|
||||
# vendor router imports from; the imports below are the public surface.
|
||||
from .alpha_vantage_fundamentals import (
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_fundamentals,
|
||||
get_income_statement,
|
||||
)
|
||||
from .alpha_vantage_indicator import get_indicator
|
||||
from .alpha_vantage_fundamentals import get_fundamentals, get_balance_sheet, get_cashflow, get_income_statement
|
||||
from .alpha_vantage_news import get_news, get_global_news, get_insider_transactions
|
||||
from .alpha_vantage_news import get_global_news, get_insider_transactions, get_news
|
||||
from .alpha_vantage_stock import get_stock
|
||||
|
||||
__all__ = [
|
||||
"get_balance_sheet",
|
||||
"get_cashflow",
|
||||
"get_fundamentals",
|
||||
"get_income_statement",
|
||||
"get_indicator",
|
||||
"get_global_news",
|
||||
"get_insider_transactions",
|
||||
"get_news",
|
||||
"get_stock",
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
from .alpha_vantage_common import _make_api_request, AlphaVantageNotConfiguredError
|
||||
from .alpha_vantage_common import AlphaVantageNotConfiguredError, _make_api_request
|
||||
|
||||
|
||||
def get_indicator(
|
||||
symbol: str,
|
||||
@@ -25,6 +26,7 @@ def get_indicator(
|
||||
String containing indicator values and description
|
||||
"""
|
||||
from datetime import datetime
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
supported_indicators = {
|
||||
@@ -98,21 +100,7 @@ def get_indicator(
|
||||
"series_type": series_type,
|
||||
"datatype": "csv"
|
||||
})
|
||||
elif indicator == "macd":
|
||||
data = _make_api_request("MACD", {
|
||||
"symbol": symbol,
|
||||
"interval": interval,
|
||||
"series_type": series_type,
|
||||
"datatype": "csv"
|
||||
})
|
||||
elif indicator == "macds":
|
||||
data = _make_api_request("MACD", {
|
||||
"symbol": symbol,
|
||||
"interval": interval,
|
||||
"series_type": series_type,
|
||||
"datatype": "csv"
|
||||
})
|
||||
elif indicator == "macdh":
|
||||
elif indicator == "macd" or indicator == "macds" or indicator == "macdh":
|
||||
data = _make_api_request("MACD", {
|
||||
"symbol": symbol,
|
||||
"interval": interval,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .alpha_vantage_common import _make_api_request, format_datetime_for_api
|
||||
|
||||
|
||||
def get_news(ticker, start_date, end_date) -> dict[str, str] | str:
|
||||
"""Returns live and historical market news & sentiment data from premier news outlets worldwide.
|
||||
|
||||
@@ -68,4 +69,4 @@ def get_insider_transactions(symbol: str) -> dict[str, str] | str:
|
||||
"symbol": symbol,
|
||||
}
|
||||
|
||||
return _make_api_request("INSIDER_TRANSACTIONS", params)
|
||||
return _make_api_request("INSIDER_TRANSACTIONS", params)
|
||||
@@ -1,5 +1,7 @@
|
||||
from datetime import datetime
|
||||
from .alpha_vantage_common import _make_api_request, _filter_csv_by_date_range
|
||||
|
||||
from .alpha_vantage_common import _filter_csv_by_date_range, _make_api_request
|
||||
|
||||
|
||||
def get_stock(
|
||||
symbol: str,
|
||||
@@ -35,4 +37,4 @@ def get_stock(
|
||||
|
||||
response = _make_api_request("TIME_SERIES_DAILY_ADJUSTED", params)
|
||||
|
||||
return _filter_csv_by_date_range(response, start_date, end_date)
|
||||
return _filter_csv_by_date_range(response, start_date, end_date)
|
||||
@@ -1,10 +1,9 @@
|
||||
from copy import deepcopy
|
||||
from typing import Dict, Optional
|
||||
|
||||
import tradingagents.default_config as default_config
|
||||
|
||||
# Use default config but allow it to be overridden
|
||||
_config: Optional[Dict] = None
|
||||
_config: dict | None = None
|
||||
|
||||
|
||||
def initialize_config():
|
||||
@@ -14,7 +13,7 @@ def initialize_config():
|
||||
_config = deepcopy(default_config.DEFAULT_CONFIG)
|
||||
|
||||
|
||||
def set_config(config: Dict):
|
||||
def set_config(config: dict):
|
||||
"""Update the configuration with custom values.
|
||||
|
||||
Dict-valued keys (e.g. ``data_vendors``) are merged one level deep so a
|
||||
@@ -31,7 +30,7 @@ def set_config(config: Dict):
|
||||
_config[key] = value
|
||||
|
||||
|
||||
def get_config() -> Dict:
|
||||
def get_config() -> dict:
|
||||
"""Get the current configuration."""
|
||||
if _config is None:
|
||||
initialize_config()
|
||||
|
||||
@@ -10,7 +10,7 @@ claim. Deterministic, no LLM involved.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Iterable, Optional
|
||||
from collections.abc import Iterable
|
||||
|
||||
import pandas as pd
|
||||
from stockstats import wrap
|
||||
@@ -63,7 +63,7 @@ def build_verified_market_snapshot(
|
||||
symbol: str,
|
||||
curr_date: str,
|
||||
look_back_days: int = 30,
|
||||
indicators: Optional[Iterable[str]] = None,
|
||||
indicators: Iterable[str] | None = None,
|
||||
) -> str:
|
||||
"""Render a ground-truth snapshot: latest OHLCV row, indicators, recent closes."""
|
||||
# `df` keeps the original capitalized OHLCV columns (Open/High/Low/Close/
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
import pandas as pd
|
||||
from datetime import date, timedelta, datetime
|
||||
from datetime import date, datetime, timedelta
|
||||
from typing import Annotated
|
||||
|
||||
import pandas as pd
|
||||
|
||||
SavePathType = Annotated[str, "File path to save data. If None, data is not saved."]
|
||||
|
||||
# Tickers can contain letters, digits, dot, dash, underscore, caret
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""yfinance-based news data fetching functions."""
|
||||
|
||||
from typing import Optional
|
||||
import contextlib
|
||||
from datetime import datetime
|
||||
|
||||
import yfinance as yf
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from .config import get_config
|
||||
@@ -28,10 +28,8 @@ def _extract_article_data(article: dict) -> dict:
|
||||
pub_date_str = content.get("pubDate", "")
|
||||
pub_date = None
|
||||
if pub_date_str:
|
||||
try:
|
||||
with contextlib.suppress(ValueError, AttributeError):
|
||||
pub_date = datetime.fromisoformat(pub_date_str.replace("Z", "+00:00"))
|
||||
except (ValueError, AttributeError):
|
||||
pass
|
||||
|
||||
return {
|
||||
"title": title,
|
||||
@@ -47,10 +45,8 @@ def _extract_article_data(article: dict) -> dict:
|
||||
pub_date = None
|
||||
ts = article.get("providerPublishTime")
|
||||
if ts:
|
||||
try:
|
||||
with contextlib.suppress(ValueError, OSError, TypeError):
|
||||
pub_date = datetime.fromtimestamp(ts)
|
||||
except (ValueError, OSError, TypeError):
|
||||
pass
|
||||
return {
|
||||
"title": article.get("title", "No title"),
|
||||
"summary": article.get("summary", ""),
|
||||
@@ -131,8 +127,8 @@ def get_news_yfinance(
|
||||
|
||||
def get_global_news_yfinance(
|
||||
curr_date: str,
|
||||
look_back_days: Optional[int] = None,
|
||||
limit: Optional[int] = None,
|
||||
look_back_days: int | None = None,
|
||||
limit: int | None = None,
|
||||
) -> str:
|
||||
"""
|
||||
Retrieve global/macro economic news using yfinance Search.
|
||||
|
||||
Reference in new issue
Block a user