From 20a9ae5ee7abfe85a458c95a41c4d7254f88b657 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Fri, 3 Jan 2025 03:43:03 +0100 Subject: [PATCH] avoid enforce_typing because it's slow --- fin_defs/__init__.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/fin_defs/__init__.py b/fin_defs/__init__.py index 2cf05d2..4b2a1c7 100644 --- a/fin_defs/__init__.py +++ b/fin_defs/__init__.py @@ -23,8 +23,6 @@ import re from collections.abc import Mapping from decimal import Decimal -import enforce_typing - from ._version import __version__ __all__ = [ @@ -67,7 +65,6 @@ RE_TICKER_FORMAT_FLEXIBLE = r'^[^:\s](?:[^:]*[^:\s])?$' RE_CRYPTO_TICKER_FORMAT = r'^\S+$' -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True) class StockExchange: """Unified Stock Exchange identifiers. @@ -97,7 +94,6 @@ NYSE = StockExchange( ) -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True) class Asset: """An identifier representing some abstract financial asset. @@ -216,7 +212,6 @@ class Asset: return self.to_string_id() -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True) class UnknownAsset(Asset): """An asset that does not exist.""" @@ -226,13 +221,11 @@ class UnknownAsset(Asset): return '???' -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True) class Currency(Asset): """Either a Fiat or a Crypto Currency.""" -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True, eq=True, order=True) class FiatCurrency(Currency): """Fiat Currency.""" @@ -266,7 +259,6 @@ FiatCurrency.GBP = FiatCurrency('GBP') FiatCurrency.JPY = FiatCurrency('JPY') -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True, eq=True) class CryptoCurrency(Currency): """Crypto Currency.""" @@ -278,7 +270,6 @@ class CryptoCurrency(Currency): return self.ccxt_symbol -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True, eq=True) class Stock(Asset): ticker: str @@ -298,7 +289,6 @@ class Stock(Asset): return self.ticker -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True, eq=True) class Index(Asset): ticker: str @@ -312,7 +302,6 @@ class Index(Asset): return self.ticker -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True, eq=True) class Commodity(Asset): alpha_vantage_id: str @@ -490,7 +479,6 @@ if True: del add_by_id -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True, slots=True) class AssetInformation: """Extensive information about a given asset.""" @@ -512,7 +500,6 @@ def assert_same_asset(do: str, a_asset: 'AssetAmount', b_asset: 'AssetAmount'): raise ValueError(msg) -@enforce_typing.enforce_types @dataclasses.dataclass(frozen=True, eq=True, slots=True) class AssetAmount: """Decimal with associated asset unit.