Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpolygon committed Jan 9, 2025
1 parent 31a36f3 commit 04446fd
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions polygon/rest/models/financials.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import Optional, Dict, List
from dataclasses import dataclass
from typing import Any, Dict, List, Optional
from ...modelclass import modelclass


@modelclass
@dataclass
class DataPoint:
"""Represents a single numeric or textual data point in the financials."""

Expand All @@ -16,7 +18,7 @@ class DataPoint:
xpath: Optional[str] = None

@staticmethod
def from_dict(d: dict) -> "DataPoint":
def from_dict(d: Optional[Dict[str, Any]]) -> "DataPoint":
if not d:
return DataPoint()
return DataPoint(
Expand All @@ -31,6 +33,7 @@ def from_dict(d: dict) -> "DataPoint":
)


@dataclass
@modelclass
class BalanceSheet:
assets: Optional[DataPoint] = None
Expand Down Expand Up @@ -68,10 +71,9 @@ class BalanceSheet:
liabilities_and_equity: Optional[DataPoint] = None

@staticmethod
def from_dict(d: dict) -> "BalanceSheet":
def from_dict(d: Optional[Dict[str, Any]]) -> "BalanceSheet":
if not d:
return BalanceSheet()

return BalanceSheet(
assets=DataPoint.from_dict(d.get("assets")),
current_assets=DataPoint.from_dict(d.get("current_assets")),
Expand Down Expand Up @@ -133,9 +135,9 @@ def from_dict(d: dict) -> "BalanceSheet":
)


@dataclass
@modelclass
class CashFlowStatement:

net_cash_flow_from_operating_activities: Optional[DataPoint] = None
net_cash_flow_from_operating_activities_continuing: Optional[DataPoint] = None
net_cash_flow_from_operating_activities_discontinued: Optional[DataPoint] = None
Expand All @@ -151,10 +153,9 @@ class CashFlowStatement:
net_cash_flow_discontinued: Optional[DataPoint] = None

@staticmethod
def from_dict(d: dict) -> "CashFlowStatement":
def from_dict(d: Optional[Dict[str, Any]]) -> "CashFlowStatement":
if not d:
return CashFlowStatement()

return CashFlowStatement(
net_cash_flow_from_operating_activities=DataPoint.from_dict(
d.get("net_cash_flow_from_operating_activities")
Expand Down Expand Up @@ -194,9 +195,9 @@ def from_dict(d: dict) -> "CashFlowStatement":
)


@dataclass
@modelclass
class ComprehensiveIncome:

comprehensive_income_loss: Optional[DataPoint] = None
comprehensive_income_loss_attributable_to_noncontrolling_interest: Optional[
DataPoint
Expand All @@ -209,10 +210,9 @@ class ComprehensiveIncome:
other_comprehensive_income_loss_attributable_to_parent: Optional[DataPoint] = None

@staticmethod
def from_dict(d: dict) -> "ComprehensiveIncome":
def from_dict(d: Optional[Dict[str, Any]]) -> "ComprehensiveIncome":
if not d:
return ComprehensiveIncome()

return ComprehensiveIncome(
comprehensive_income_loss=DataPoint.from_dict(
d.get("comprehensive_income_loss")
Expand All @@ -239,9 +239,9 @@ def from_dict(d: dict) -> "ComprehensiveIncome":
)


@dataclass
@modelclass
class IncomeStatement:

revenues: Optional[DataPoint] = None
benefits_costs_expenses: Optional[DataPoint] = None
cost_of_revenue: Optional[DataPoint] = None
Expand Down Expand Up @@ -310,7 +310,7 @@ class IncomeStatement:
common_stock_dividends: Optional[DataPoint] = None

@staticmethod
def from_dict(d: dict) -> "IncomeStatement":
def from_dict(d: Optional[Dict[str, Any]]) -> "IncomeStatement":
if not d:
return IncomeStatement()
return IncomeStatement(
Expand Down Expand Up @@ -457,6 +457,7 @@ def from_dict(d: dict) -> "IncomeStatement":
)


@dataclass
@modelclass
class Financials:
"""
Expand All @@ -473,7 +474,7 @@ class Financials:
income_statement: Optional[IncomeStatement] = None

@staticmethod
def from_dict(d: dict) -> "Financials":
def from_dict(d: Optional[Dict[str, Any]]) -> "Financials":
if not d:
return Financials()
return Financials(
Expand All @@ -488,6 +489,7 @@ def from_dict(d: dict) -> "Financials":
)


@dataclass
@modelclass
class StockFinancial:
"""
Expand All @@ -508,7 +510,7 @@ class StockFinancial:
start_date: Optional[str] = None

@staticmethod
def from_dict(d: dict) -> "StockFinancial":
def from_dict(d: Optional[Dict[str, Any]]) -> "StockFinancial":
if not d:
return StockFinancial()
return StockFinancial(
Expand Down

0 comments on commit 04446fd

Please sign in to comment.