mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-31 06:22:18 +00:00
Add some docstrings
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
"""Base models for OpenBB Provider. """
|
||||
from typing import List, Literal, Optional, Union
|
||||
|
||||
from pydantic import BaseModel, Field, NonNegativeInt, validator
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
"""CPI data and query params."""
|
||||
from datetime import date as dateType
|
||||
from typing import List, Literal, Optional
|
||||
|
||||
@@ -101,6 +102,7 @@ class CPIData(Data):
|
||||
|
||||
@validator("value", pre=True)
|
||||
def value_validate(cls, v: str): # pylint: disable=E0213
|
||||
"""Validate value."""
|
||||
if v == ".":
|
||||
return 0.0
|
||||
return float(v)
|
||||
|
||||
@@ -9,6 +9,8 @@ from openbb_provider.abstract.data import Data
|
||||
|
||||
|
||||
class FinancialRatiosData(Data):
|
||||
"""Financial ratios data model."""
|
||||
|
||||
symbol: str = Field(description="The symbol of the company.")
|
||||
date: str = Field(description="The date of the financial ratios.")
|
||||
period: str = Field(description="The period of the financial ratios.")
|
||||
|
||||
@@ -36,18 +36,21 @@ class HistoricalDividendsData(Data):
|
||||
|
||||
@validator("declaration_date", pre=True, check_fields=False)
|
||||
def declaration_date_validate(cls, v: str): # pylint: disable=E0213
|
||||
"""Declaration date validator."""
|
||||
if not isinstance(v, str):
|
||||
return v
|
||||
return dateType.fromisoformat(v) if v else None
|
||||
|
||||
@validator("record_date", pre=True, check_fields=False)
|
||||
def record_date_validate(cls, v: str): # pylint: disable=E0213
|
||||
"""Record date validator."""
|
||||
if not isinstance(v, str):
|
||||
return v
|
||||
return dateType.fromisoformat(v) if v else None
|
||||
|
||||
@validator("payment_date", pre=True, check_fields=False)
|
||||
def payment_date_validate(cls, v: str): # pylint: disable=E0213
|
||||
"""Payment date validator."""
|
||||
if not isinstance(v, str):
|
||||
return v
|
||||
return dateType.fromisoformat(v) if v else None
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""Historical Employees data model."""
|
||||
|
||||
|
||||
from datetime import date, datetime
|
||||
|
||||
from pydantic import Field, validator
|
||||
@@ -38,12 +37,15 @@ class HistoricalEmployeesData(Data, BaseSymbol):
|
||||
|
||||
@validator("acceptance_time", pre=True, check_fields=False)
|
||||
def acceptance_time_validate(cls, v): # pylint: disable=E0213
|
||||
"""Validate acceptance time."""
|
||||
return datetime.strptime(v, "%Y-%m-%d %H:%M:%S")
|
||||
|
||||
@validator("period_of_report", pre=True, check_fields=False)
|
||||
def period_of_report_validate(cls, v): # pylint: disable=E0213
|
||||
"""Validate period of report."""
|
||||
return datetime.strptime(v, "%Y-%m-%d")
|
||||
|
||||
@validator("filing_date", pre=True, check_fields=False)
|
||||
def filing_date_validate(cls, v): # pylint: disable=E0213
|
||||
"""Validate filing date."""
|
||||
return datetime.strptime(v, "%Y-%m-%d")
|
||||
|
||||
@@ -24,6 +24,7 @@ class StockNewsQueryParams(QueryParams):
|
||||
|
||||
@validator("symbols", pre=True)
|
||||
def symbols_validate(cls, v: str): # pylint: disable=E0213
|
||||
"""Validate the symbols."""
|
||||
return v.upper()
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ class StockOwnershipQueryParams(QueryParams, BaseSymbol):
|
||||
)
|
||||
|
||||
@validator("date", pre=True, check_fields=False)
|
||||
def time_validate(cls, v: str): # pylint: disable=E0213
|
||||
def time_validate(cls, v: str): # pylint: disable=E021
|
||||
"""Validate the date."""
|
||||
if v is None:
|
||||
v = dateType.today()
|
||||
if isinstance(v, str):
|
||||
|
||||
Reference in New Issue
Block a user