Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 25 additions & 6 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python Linting & Unit Tests
name: Python Checks

permissions:
contents: read
Expand All @@ -21,18 +21,37 @@ jobs:
working-directory: ./python

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Install Ruff
uses: astral-sh/ruff-action@v3

- name: Ruff Format
run: ruff format --check --config ./pyproject.toml .

- name: Ruff Lint
run: ruff check --config ./pyproject.toml .

unit_test:
style:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python
steps:
- uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: "./python/pyproject.toml"

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Install style dependencies
run: uv sync --locked --only-group style

- name: Run style checks
run: uv run --no-project isort --check-only ./valuecell

test:
runs-on: ubuntu-latest
defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
format:
ruff format --config ./python/pyproject.toml ./python/
ruff format --config ./python/pyproject.toml ./python/ && uv run --directory ./python isort .

lint:
ruff check --config ./python/pyproject.toml ./python/
Expand Down
16 changes: 16 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ dev = [
[dependency-groups]
dev = [
{include-group = "lint"},
{include-group = "style"},
{include-group = "test"}
]
lint = [
"ruff"
]
style = [
"ruff",
"isort",
]
test = [
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
Expand Down Expand Up @@ -95,3 +100,14 @@ norecursedirs = [
"examples",
"docs",
]

[tool.isort]
profile = "black"
skip_glob = [
"third_party/**",
"**/third_party/**",
"tests/**",
"**/tests/**",
"docs/**",
"**/docs/**",
]
19 changes: 19 additions & 0 deletions python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 29 additions & 28 deletions python/valuecell/adapters/assets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,28 @@
```
"""

# Core types and data structures
from .types import (
Asset,
AssetPrice,
AssetSearchResult,
AssetSearchQuery,
AssetType,
MarketStatus,
DataSource,
MarketInfo,
LocalizedName,
Watchlist,
WatchlistItem,
)
from .akshare_adapter import AKShareAdapter

# Base adapter classes
from .base import (
BaseDataAdapter,
TickerConverter,
AdapterError,
RateLimitError,
DataNotAvailableError,
AuthenticationError,
BaseDataAdapter,
DataNotAvailableError,
InvalidTickerError,
RateLimitError,
TickerConverter,
)

# Specific adapter implementations
from .yfinance_adapter import YFinanceAdapter
from .tushare_adapter import TuShareAdapter
from .coinmarketcap_adapter import CoinMarketCapAdapter
from .akshare_adapter import AKShareAdapter
from .finnhub_adapter import FinnhubAdapter

# Internationalization support
from .i18n_integration import (
AssetI18nService,
get_asset_i18n_service,
reset_asset_i18n_service,
)

# Management and coordination
from .manager import (
AdapterManager,
Expand All @@ -75,14 +64,26 @@
get_watchlist_manager,
reset_managers,
)
from .tushare_adapter import TuShareAdapter

# Internationalization support
from .i18n_integration import (
AssetI18nService,
get_asset_i18n_service,
reset_asset_i18n_service,
# Core types and data structures
from .types import (
Asset,
AssetPrice,
AssetSearchQuery,
AssetSearchResult,
AssetType,
DataSource,
LocalizedName,
MarketInfo,
MarketStatus,
Watchlist,
WatchlistItem,
)

# Specific adapter implementations
from .yfinance_adapter import YFinanceAdapter

# Note: High-level asset service functions have been moved to valuecell.services.assets
# Import from there for asset search, price retrieval, and watchlist operations

Expand Down
15 changes: 8 additions & 7 deletions python/valuecell/adapters/assets/akshare_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
Global financial market data including stocks, funds, bonds, and economic indicators.
"""

import decimal
import logging
from typing import List, Optional, Any
import threading
import time
from datetime import datetime, timedelta
from decimal import Decimal
import decimal
from typing import Any, List, Optional

import pandas as pd
import time
import threading

try:
import akshare as ak
Expand All @@ -22,12 +23,12 @@
from .types import (
Asset,
AssetPrice,
AssetSearchResult,
AssetSearchQuery,
DataSource,
AssetSearchResult,
AssetType,
MarketInfo,
DataSource,
LocalizedName,
MarketInfo,
MarketStatus,
)

Expand Down
8 changes: 4 additions & 4 deletions python/valuecell/adapters/assets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
must implement to ensure consistent behavior across different providers.
"""

import logging
from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Any
from datetime import datetime
import logging
from typing import Any, Dict, List, Optional

from .types import (
Asset,
AssetPrice,
AssetSearchResult,
AssetSearchQuery,
DataSource,
AssetSearchResult,
AssetType,
DataSource,
)

logger = logging.getLogger(__name__)
Expand Down
13 changes: 7 additions & 6 deletions python/valuecell/adapters/assets/coinmarketcap_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@
"""

import logging
from typing import Dict, List, Optional, Any
import time
from datetime import datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional

import requests
import time

from .base import (
AuthenticationError,
BaseDataAdapter,
DataNotAvailableError,
AuthenticationError,
RateLimitError,
)
from .types import (
Asset,
AssetPrice,
AssetSearchResult,
AssetSearchQuery,
DataSource,
AssetSearchResult,
AssetType,
MarketInfo,
DataSource,
LocalizedName,
MarketInfo,
MarketStatus,
)

Expand Down
13 changes: 7 additions & 6 deletions python/valuecell/adapters/assets/finnhub_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@
"""

import logging
from typing import Dict, List, Optional, Any
import time
from datetime import datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional

import requests
import time

from .base import (
AuthenticationError,
BaseDataAdapter,
DataNotAvailableError,
AuthenticationError,
RateLimitError,
)
from .types import (
Asset,
AssetPrice,
AssetSearchResult,
AssetSearchQuery,
DataSource,
AssetSearchResult,
AssetType,
MarketInfo,
DataSource,
LocalizedName,
MarketInfo,
MarketStatus,
)

Expand Down
5 changes: 2 additions & 3 deletions python/valuecell/adapters/assets/i18n_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import logging
from typing import Dict, List, Optional

from ...server.config.i18n import I18nConfig, get_i18n_config
from ...server.services.i18n_service import get_i18n_service, t
from ...server.config.i18n import get_i18n_config
from ...server.config.i18n import I18nConfig
from .types import Asset, AssetSearchResult, AssetType, MarketStatus
from .manager import AdapterManager
from .types import Asset, AssetSearchResult, AssetType, MarketStatus

logger = logging.getLogger(__name__)

Expand Down
Loading