Skip to content

Commit

Permalink
type sync filter and ignore typing for async filter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pacrob committed Dec 7, 2022
1 parent d842245 commit fd5cfa5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion web3/_utils/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ async def deploy(self, async_w3: "Web3") -> "AsyncLogFilter":
arg._immutable = True
self._immutable = True

log_filter = await async_w3.eth.filter(self.filter_params)
log_filter = await async_w3.eth.filter(self.filter_params) # type: ignore
log_filter.filter_params = self.filter_params
log_filter.set_data_filters(self.data_argument_values)
log_filter.builder = self
Expand Down
8 changes: 4 additions & 4 deletions web3/_utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ async def test_eth_getBlockTransactionCountByNumber_block_with_txn(

@pytest.mark.asyncio
async def test_async_eth_new_filter(self, async_w3: "Web3") -> None:
filter = await async_w3.eth.filter({})
filter = await async_w3.eth.filter({}) # type: ignore

changes = await async_w3.eth.get_filter_changes(
filter.filter_id
Expand All @@ -1484,7 +1484,7 @@ async def test_async_eth_new_filter(self, async_w3: "Web3") -> None:

@pytest.mark.asyncio
async def test_async_eth_new_block_filter(self, async_w3: "Web3") -> None:
filter = await async_w3.eth.filter("latest")
filter = await async_w3.eth.filter("latest") # type: ignore
assert is_string(filter.filter_id)

changes = await async_w3.eth.get_filter_changes(
Expand All @@ -1500,7 +1500,7 @@ async def test_async_eth_new_block_filter(self, async_w3: "Web3") -> None:
async def test_async_eth_new_pending_transaction_filter(
self, async_w3: "Web3"
) -> None:
filter = await async_w3.eth.filter("pending")
filter = await async_w3.eth.filter("pending") # type: ignore
assert is_string(filter.filter_id)

changes = await async_w3.eth.get_filter_changes(
Expand All @@ -1514,7 +1514,7 @@ async def test_async_eth_new_pending_transaction_filter(

@pytest.mark.asyncio
async def test_async_eth_uninstall_filter(self, async_w3: "Web3") -> None:
filter = await async_w3.eth.filter({})
filter = await async_w3.eth.filter({}) # type: ignore
assert is_string(filter.filter_id)

success = await async_w3.eth.uninstall_filter(filter.filter_id) # type: ignore
Expand Down
9 changes: 7 additions & 2 deletions web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
)
from web3._utils.filters import (
AsyncFilter,
Filter,
select_filter_method,
)
from web3._utils.rpc_abi import (
Expand Down Expand Up @@ -635,7 +636,9 @@ async def get_storage_at(
) -> HexBytes:
return await self._get_storage_at(account, position, block_identifier)

filter: Method[Callable[..., Awaitable[AsyncFilter]]] = Method(
filter: Method[
Callable[[Optional[Union[str, FilterParams, HexStr]]], Awaitable[AsyncFilter]]
] = Method(
method_choice_depends_on_args=select_filter_method(
if_new_block_filter=RPC.eth_newBlockFilter,
if_new_pending_transaction_filter=RPC.eth_newPendingTransactionFilter,
Expand Down Expand Up @@ -958,7 +961,9 @@ def fee_history(
) -> FeeHistory:
return self._fee_history(block_count, newest_block, reward_percentiles)

filter: Method[Callable[..., Any]] = Method(
filter: Method[
Callable[[Optional[Union[str, FilterParams, HexStr]]], Filter]
] = Method(
method_choice_depends_on_args=select_filter_method(
if_new_block_filter=RPC.eth_newBlockFilter,
if_new_pending_transaction_filter=RPC.eth_newPendingTransactionFilter,
Expand Down

0 comments on commit fd5cfa5

Please sign in to comment.