From 7b643a2f92c2c9fa1aa7f2d2186a83764b40a3e6 Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Tue, 15 Aug 2023 12:43:59 +0200 Subject: [PATCH] Add some docstrings --- .../sdk/provider/openbb_provider/standard_models/base.py | 1 + .../sdk/provider/openbb_provider/standard_models/cpi.py | 2 ++ .../openbb_provider/standard_models/financial_ratios.py | 2 ++ .../openbb_provider/standard_models/historical_dividends.py | 3 +++ .../openbb_provider/standard_models/historical_employees.py | 4 +++- .../provider/openbb_provider/standard_models/stock_news.py | 1 + .../openbb_provider/standard_models/stock_ownership.py | 3 ++- 7 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openbb_sdk/sdk/provider/openbb_provider/standard_models/base.py b/openbb_sdk/sdk/provider/openbb_provider/standard_models/base.py index dadef97e707..53fc2436fb3 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/standard_models/base.py +++ b/openbb_sdk/sdk/provider/openbb_provider/standard_models/base.py @@ -1,3 +1,4 @@ +"""Base models for OpenBB Provider. """ from typing import List, Literal, Optional, Union from pydantic import BaseModel, Field, NonNegativeInt, validator diff --git a/openbb_sdk/sdk/provider/openbb_provider/standard_models/cpi.py b/openbb_sdk/sdk/provider/openbb_provider/standard_models/cpi.py index a80ab017d69..973b57b4ff1 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/standard_models/cpi.py +++ b/openbb_sdk/sdk/provider/openbb_provider/standard_models/cpi.py @@ -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) diff --git a/openbb_sdk/sdk/provider/openbb_provider/standard_models/financial_ratios.py b/openbb_sdk/sdk/provider/openbb_provider/standard_models/financial_ratios.py index 2b40b054a12..ea6d90f2bce 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/standard_models/financial_ratios.py +++ b/openbb_sdk/sdk/provider/openbb_provider/standard_models/financial_ratios.py @@ -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.") diff --git a/openbb_sdk/sdk/provider/openbb_provider/standard_models/historical_dividends.py b/openbb_sdk/sdk/provider/openbb_provider/standard_models/historical_dividends.py index 0e2cbc593b2..14f56fb7fd5 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/standard_models/historical_dividends.py +++ b/openbb_sdk/sdk/provider/openbb_provider/standard_models/historical_dividends.py @@ -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 diff --git a/openbb_sdk/sdk/provider/openbb_provider/standard_models/historical_employees.py b/openbb_sdk/sdk/provider/openbb_provider/standard_models/historical_employees.py index ecaa80f06be..4df63de561a 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/standard_models/historical_employees.py +++ b/openbb_sdk/sdk/provider/openbb_provider/standard_models/historical_employees.py @@ -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") diff --git a/openbb_sdk/sdk/provider/openbb_provider/standard_models/stock_news.py b/openbb_sdk/sdk/provider/openbb_provider/standard_models/stock_news.py index 8efa53be3a8..73f72dbc951 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/standard_models/stock_news.py +++ b/openbb_sdk/sdk/provider/openbb_provider/standard_models/stock_news.py @@ -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() diff --git a/openbb_sdk/sdk/provider/openbb_provider/standard_models/stock_ownership.py b/openbb_sdk/sdk/provider/openbb_provider/standard_models/stock_ownership.py index 8948d0d8886..a6a0600be86 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/standard_models/stock_ownership.py +++ b/openbb_sdk/sdk/provider/openbb_provider/standard_models/stock_ownership.py @@ -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):