Skip to content

Commit

Permalink
fix: Remove model_config for sphinx (#474)
Browse files Browse the repository at this point in the history
* fix: remove model_config for sphinx

* fix: add noqa unused-import into a import for sphinx
  • Loading branch information
hiohiohio authored Jun 27, 2024
1 parent 296ac38 commit 6e3f3a9
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 47 deletions.
2 changes: 0 additions & 2 deletions alpaca/data/models/bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class Bar(BaseModel):
trade_count: Optional[float]
vwap: Optional[float]

model_config = ConfigDict(protected_namespaces=tuple())

def __init__(self, symbol: str, raw_data: RawData) -> None:
"""Instantiates a bar
Expand Down
1 change: 0 additions & 1 deletion alpaca/data/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class BaseDataSet(BaseModel):
"""

data: Dict[str, List[BaseModel]] = {}
model_config = ConfigDict(protected_namespaces=tuple())

def __getitem__(self, symbol: str) -> Any:
"""Gives dictionary-like access to multi-symbol data
Expand Down
4 changes: 0 additions & 4 deletions alpaca/data/models/orderbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class OrderbookQuote(BaseModel):
price: float = Field(alias="p")
size: float = Field(alias="s")

model_config = ConfigDict(protected_namespaces=tuple())


class Orderbook(BaseModel):
"""Level 2 ask/bid pair orderbook data.
Expand All @@ -32,8 +30,6 @@ class Orderbook(BaseModel):
bids: List[OrderbookQuote]
asks: List[OrderbookQuote]

model_config = ConfigDict(protected_namespaces=tuple())

def __init__(self, symbol: str, raw_data: RawData) -> None:
"""Instantiates an Orderbook.
Expand Down
2 changes: 0 additions & 2 deletions alpaca/data/models/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class Quote(BaseModel):
conditions: Optional[Union[List[str], str]] = None
tape: Optional[str] = None

model_config = ConfigDict(protected_namespaces=tuple())

def __init__(self, symbol: str, raw_data: RawData) -> None:
"""Instantiates a Quote
Expand Down
8 changes: 0 additions & 8 deletions alpaca/data/models/screener.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class ActiveStock(BaseModel):
volume: float
trade_count: float

model_config = ConfigDict(protected_namespaces=tuple())


class MostActives(BaseModel):
"""
Expand All @@ -37,8 +35,6 @@ class MostActives(BaseModel):
most_actives: List[ActiveStock]
last_updated: datetime

model_config = ConfigDict(protected_namespaces=tuple())


class Mover(BaseModel):
"""
Expand All @@ -55,8 +51,6 @@ class Mover(BaseModel):
change: float
price: float

model_config = ConfigDict(protected_namespaces=tuple())


class Movers(BaseModel):
"""
Expand All @@ -74,5 +68,3 @@ class Movers(BaseModel):
losers: List[Mover]
market_type: MarketType
last_updated: datetime

model_config = ConfigDict(protected_namespaces=tuple())
6 changes: 0 additions & 6 deletions alpaca/data/models/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class Snapshot(BaseModel):
daily_bar: Optional[Bar] = None
previous_daily_bar: Optional[Bar] = None

model_config = ConfigDict(protected_namespaces=tuple())

def __init__(self, symbol: str, raw_data: Dict[str, RawData]) -> None:
"""Instantiates a Snapshot.
Expand Down Expand Up @@ -81,8 +79,6 @@ class OptionsGreeks(BaseModel):
theta: float
vega: float

model_config = ConfigDict(protected_namespaces=tuple())

def __init__(self, raw_data: RawData) -> None:
"""Instantiates an OptionGreeks object.
Expand Down Expand Up @@ -110,8 +106,6 @@ class OptionsSnapshot(BaseModel):
implied_volatility: Optional[float] = None
greeks: Optional[OptionsGreeks] = None

model_config = ConfigDict(protected_namespaces=tuple())

def __init__(self, symbol: str, raw_data: Dict[str, RawData]) -> None:
"""Instantiates a Snapshot.
Expand Down
2 changes: 0 additions & 2 deletions alpaca/data/models/trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class Trade(BaseModel):
conditions: Optional[Union[List[str], str]] = None
tape: Optional[str] = None

model_config = ConfigDict(protected_namespaces=tuple())

def __init__(self, symbol: str, raw_data: RawData) -> None:
"""Instantiates a Trade history object
Expand Down
22 changes: 0 additions & 22 deletions alpaca/data/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class BaseTimeseriesDataRequest(NonEmptyRequest):
currency: Optional[SupportedCurrencies] = None # None = USD
sort: Optional[Sort] = None # None = asc

model_config = ConfigDict(protected_namespaces=tuple())

def __init__(self, **data: Any) -> None:
# convert timezone aware datetime to timezone naive UTC datetime
if (
Expand Down Expand Up @@ -242,8 +240,6 @@ class BaseStockLatestDataRequest(NonEmptyRequest):
feed: Optional[DataFeed] = None
currency: Optional[SupportedCurrencies] = None # None = USD

model_config = ConfigDict(protected_namespaces=tuple())


class StockLatestTradeRequest(BaseStockLatestDataRequest):
"""
Expand Down Expand Up @@ -301,8 +297,6 @@ class BaseCryptoLatestDataRequest(NonEmptyRequest):

symbol_or_symbols: Union[str, List[str]]

model_config = ConfigDict(protected_namespaces=tuple())


class CryptoLatestTradeRequest(BaseCryptoLatestDataRequest):
"""
Expand Down Expand Up @@ -356,8 +350,6 @@ class BaseOptionLatestDataRequest(NonEmptyRequest):
symbol_or_symbols: Union[str, List[str]]
feed: Optional[OptionsFeed] = None

model_config = ConfigDict(protected_namespaces=tuple())


class OptionLatestQuoteRequest(BaseOptionLatestDataRequest):
"""
Expand Down Expand Up @@ -404,8 +396,6 @@ class StockSnapshotRequest(NonEmptyRequest):
feed: Optional[DataFeed] = None
currency: Optional[SupportedCurrencies] = None # None = USD

model_config = ConfigDict(protected_namespaces=tuple())


class CryptoSnapshotRequest(NonEmptyRequest):
"""
Expand All @@ -417,8 +407,6 @@ class CryptoSnapshotRequest(NonEmptyRequest):

symbol_or_symbols: Union[str, List[str]]

model_config = ConfigDict(protected_namespaces=tuple())


class OptionSnapshotRequest(NonEmptyRequest):
"""
Expand All @@ -432,8 +420,6 @@ class OptionSnapshotRequest(NonEmptyRequest):
symbol_or_symbols: Union[str, List[str]]
feed: Optional[OptionsFeed] = None

model_config = ConfigDict(protected_namespaces=tuple())


class OptionChainRequest(NonEmptyRequest):
"""
Expand Down Expand Up @@ -461,8 +447,6 @@ class OptionChainRequest(NonEmptyRequest):
expiration_date_lte: Optional[Union[date, str]] = None
root_symbol: Optional[str] = None

model_config = ConfigDict(protected_namespaces=tuple())


# ############################## Orderbooks ################################# #

Expand All @@ -477,8 +461,6 @@ class CryptoLatestOrderbookRequest(NonEmptyRequest):

symbol_or_symbols: Union[str, List[str]]

model_config = ConfigDict(protected_namespaces=tuple())


# ############################## Screener #################################### #

Expand All @@ -493,8 +475,6 @@ class ScreenerRequest(NonEmptyRequest):

top: int = 10

model_config = ConfigDict(protected_namespaces=tuple())


class MostActivesRequest(ScreenerRequest):
"""
Expand Down Expand Up @@ -546,5 +526,3 @@ class NewsRequest(NonEmptyRequest):
include_content: Optional[bool] = None
exclude_contentless: Optional[bool] = None
page_token: Optional[str] = None

model_config = ConfigDict(protected_namespaces=tuple())
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

sys.path.insert(0, os.path.abspath("../"))

# import a module here to avoid an error of:
# NameError: Field "model_fields" conflicts with member {} of protected namespace "model_".
# ref. https://github.com/pydantic/pydantic/discussions/7763#discussioncomment-8417097
import alpaca.data.models.screener # noqa # pylint: disable=unused-import

# -- Project information -----------------------------------------------------

project = "alpaca-py"
Expand Down

0 comments on commit 6e3f3a9

Please sign in to comment.