From 00d1b63755dd89c5a2c45d6299342e7986b18fad Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:09:21 -0400 Subject: [PATCH 1/2] fix: pony-stubs runtime err --- eth_portfolio/_db/entities.py | 39 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/eth_portfolio/_db/entities.py b/eth_portfolio/_db/entities.py index 26158c52..b2edbfc0 100644 --- a/eth_portfolio/_db/entities.py +++ b/eth_portfolio/_db/entities.py @@ -12,26 +12,41 @@ class BlockExtended(Block): - transactions: Set["Transaction"] = Set("Transaction", lazy=True, reverse="block") - internal_transfers: Set["InternalTransfer"] = Set( + if typing.TYPE_CHECKING: + # if we execute this code we get `TypeError: 'type' object is not subscriptable` + transactions: Set["Transaction"] + internal_transfers: Set["InternalTransfer"] + token_transfers: Set["TokenTransfer"] + + transactions = Set("Transaction", lazy=True, reverse="block") + internal_transfers = Set( "InternalTransfer", lazy=True, reverse="block" ) - token_transfers: Set["TokenTransfer"] = Set("TokenTransfer", lazy=True, reverse="block") + token_transfers = Set("TokenTransfer", lazy=True, reverse="block") class AddressExtended(Address): - transactions_sent: Set["Transaction"] = Set("Transaction", lazy=True, reverse="from_address") - transactions_received: Set["Transaction"] = Set("Transaction", lazy=True, reverse="to_address") - internal_transfers_sent: Set["InternalTransfer"] = Set( + if typing.TYPE_CHECKING: + # if we execute this code we get `TypeError: 'type' object is not subscriptable` + transactions_sent: Set["Transaction"] + transactions_received: Set["Transaction"] + internal_transfers_sent: Set["InternalTransfer"] + internal_transfers_received: Set["InternalTransfer"] + token_transfers_sent: Set["TokenTransfer"] + token_transfers_received: Set["TokenTransfer"] + + transactions_sent = Set("Transaction", lazy=True, reverse="from_address") + transactions_received = Set("Transaction", lazy=True, reverse="to_address") + internal_transfers_sent = Set( "InternalTransfer", lazy=True, reverse="from_address" ) - internal_transfers_received: Set["InternalTransfer"] = Set( + internal_transfers_received = Set( "InternalTransfer", lazy=True, reverse="to_address" ) - token_transfers_sent: Set["TokenTransfer"] = Set( + token_transfers_sent = Set( "TokenTransfer", lazy=True, reverse="from_address" ) - token_transfers_received: Set["TokenTransfer"] = Set( + token_transfers_received = Set( "TokenTransfer", lazy=True, reverse="to_address" ) @@ -41,7 +56,11 @@ class ContractExtended(Contract, AddressExtended): class TokenExtended(Token, AddressExtended): - transfers: Set["TokenTransfer"] = Set("TokenTransfer", lazy=True, reverse="token") + if typing.TYPE_CHECKING: + # if we execute this code we get `TypeError: 'type' object is not subscriptable` + transfers: Set["TokenTransfer"] + + transfers = Set("TokenTransfer", lazy=True, reverse="token") class Transaction(DbEntity): From 6686e6eb995dc80bfedc5705826d4085438eace8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 12 Nov 2024 17:10:03 +0000 Subject: [PATCH 2/2] chore: `black .` --- eth_portfolio/_db/entities.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/eth_portfolio/_db/entities.py b/eth_portfolio/_db/entities.py index b2edbfc0..47811857 100644 --- a/eth_portfolio/_db/entities.py +++ b/eth_portfolio/_db/entities.py @@ -17,11 +17,9 @@ class BlockExtended(Block): transactions: Set["Transaction"] internal_transfers: Set["InternalTransfer"] token_transfers: Set["TokenTransfer"] - + transactions = Set("Transaction", lazy=True, reverse="block") - internal_transfers = Set( - "InternalTransfer", lazy=True, reverse="block" - ) + internal_transfers = Set("InternalTransfer", lazy=True, reverse="block") token_transfers = Set("TokenTransfer", lazy=True, reverse="block") @@ -34,21 +32,13 @@ class AddressExtended(Address): internal_transfers_received: Set["InternalTransfer"] token_transfers_sent: Set["TokenTransfer"] token_transfers_received: Set["TokenTransfer"] - + transactions_sent = Set("Transaction", lazy=True, reverse="from_address") transactions_received = Set("Transaction", lazy=True, reverse="to_address") - internal_transfers_sent = Set( - "InternalTransfer", lazy=True, reverse="from_address" - ) - internal_transfers_received = Set( - "InternalTransfer", lazy=True, reverse="to_address" - ) - token_transfers_sent = Set( - "TokenTransfer", lazy=True, reverse="from_address" - ) - token_transfers_received = Set( - "TokenTransfer", lazy=True, reverse="to_address" - ) + internal_transfers_sent = Set("InternalTransfer", lazy=True, reverse="from_address") + internal_transfers_received = Set("InternalTransfer", lazy=True, reverse="to_address") + token_transfers_sent = Set("TokenTransfer", lazy=True, reverse="from_address") + token_transfers_received = Set("TokenTransfer", lazy=True, reverse="to_address") class ContractExtended(Contract, AddressExtended):