hotfix/fmp-replace-zero: Replace Zero with None in FMP Balance, Cash, Income (#5815)

* replace zeros with None in Balance, Cash, Income

* black

---------

Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
This commit is contained in:
Danglewood
2023-11-29 08:17:49 -08:00
committed by GitHub
parent ce14ee612f
commit fe53c93d64
3 changed files with 18 additions and 0 deletions

View File

@@ -92,6 +92,12 @@ class FMPBalanceSheetData(BalanceSheetData):
default=None, description="Link to the final statement."
)
@model_validator(mode="before")
@classmethod
def replace_zero(cls, values): # pylint: disable=no-self-argument
"""Check for zero values and replace with None."""
return {k: None if v == 0 else v for k, v in values.items()}
class FMPBalanceSheetFetcher(
Fetcher[

View File

@@ -99,6 +99,12 @@ class FMPCashFlowStatementData(CashFlowStatementData):
default=None, description="Link to the final statement."
)
@model_validator(mode="before")
@classmethod
def replace_zero(cls, values): # pylint: disable=no-self-argument
"""Check for zero values and replace with None."""
return {k: None if v == 0 else v for k, v in values.items()}
class FMPCashFlowStatementFetcher(
Fetcher[

View File

@@ -122,6 +122,12 @@ class FMPIncomeStatementData(IncomeStatementData):
default=None, description="Final link to the income statement."
)
@model_validator(mode="before")
@classmethod
def replace_zero(cls, values): # pylint: disable=no-self-argument
"""Check for zero values and replace with None."""
return {k: None if v == 0 else v for k, v in values.items()}
class FMPIncomeStatementFetcher(
Fetcher[