Skip to content

Commit

Permalink
test blocklint ignore line
Browse files Browse the repository at this point in the history
  • Loading branch information
pacrob committed Mar 20, 2024
1 parent f281c13 commit b51ae27
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: '.project-template|docs/conf.py|.bumpversion.cfg|ethpm/|ens/specs/|.*\.sol$'
exclude: '.project-template|docs/conf.py|.bumpversion.cfg|ethpm/|ens/specs/|.*\.sol$|normalization_tests.json'
files: 'web3/|ens/|tests/'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -34,4 +34,4 @@ repos:
rev: v0.2.4
hooks:
- id: blocklint
exclude: 'docs/Makefile|docs/release_notes.rst'
exclude: 'docs/Makefile|docs/release_notes.rst|middleware/'
2 changes: 1 addition & 1 deletion ens/async_ens.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AsyncENS(BaseENS):
like getting the address for a name.
Unless otherwise specified, all addresses are assumed to be a `str` in
`checksum format <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md>`_,
`checksum format <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md>`_, # blocklint: URL pragma # noqa: E501
like: ``"0x314159265dD8dbb310642f98f50C066173C1259b"``
"""

Expand Down
4 changes: 2 additions & 2 deletions ens/contract_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

"""
This contract data is taken from the actual ENS contracts deployed on mainnet.
The information was taken from etherscan.io and may need to be updated as the ENS
contracts are updated.
The information was taken from etherscan.io and may need to be updated as the ENS
contracts are updated.
https://etherscan.io/accounts/label/ens
"""
Expand Down
2 changes: 1 addition & 1 deletion ethpm/_utils/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from eth_utils import (
to_text,
)
from google.protobuf.descriptor import (
from google.protobuf.descriptor import ( # type: ignore
Descriptor,
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ strict_optional = false
strict_equality = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
warn_unused_ignores = false

[tool.pytest.ini_options]
addopts = "-v --showlocals --durations 10"
Expand Down
54 changes: 28 additions & 26 deletions web3/eth/async_eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class AsyncEth(BaseEth):

is_async = True

_default_contract_factory: Type[Union[AsyncContract, AsyncContractCaller]] = (
AsyncContract
)
_default_contract_factory: Type[
Union[AsyncContract, AsyncContractCaller]
] = AsyncContract

# eth_accounts

Expand Down Expand Up @@ -389,15 +389,15 @@ async def get_raw_transaction_by_block(
# eth_getBlockTransactionCountByHash
# eth_getBlockTransactionCountByNumber

get_block_transaction_count: Method[Callable[[BlockIdentifier], Awaitable[int]]] = (
Method(
method_choice_depends_on_args=select_method_for_block_identifier(
if_predefined=RPC.eth_getBlockTransactionCountByNumber,
if_hash=RPC.eth_getBlockTransactionCountByHash,
if_number=RPC.eth_getBlockTransactionCountByNumber,
),
mungers=[default_root_munger],
)
get_block_transaction_count: Method[
Callable[[BlockIdentifier], Awaitable[int]]
] = Method(
method_choice_depends_on_args=select_method_for_block_identifier(
if_predefined=RPC.eth_getBlockTransactionCountByNumber,
if_hash=RPC.eth_getBlockTransactionCountByHash,
if_number=RPC.eth_getBlockTransactionCountByNumber,
),
mungers=[default_root_munger],
)

# eth_sendTransaction
Expand All @@ -424,15 +424,15 @@ async def send_raw_transaction(self, transaction: Union[HexStr, bytes]) -> HexBy
# eth_getBlockByHash
# eth_getBlockByNumber

_get_block: Method[Callable[[BlockIdentifier, bool], Awaitable[BlockData]]] = (
Method(
method_choice_depends_on_args=select_method_for_block_identifier(
if_predefined=RPC.eth_getBlockByNumber,
if_hash=RPC.eth_getBlockByHash,
if_number=RPC.eth_getBlockByNumber,
),
mungers=[BaseEth.get_block_munger],
)
_get_block: Method[
Callable[[BlockIdentifier, bool], Awaitable[BlockData]]
] = Method(
method_choice_depends_on_args=select_method_for_block_identifier(
if_predefined=RPC.eth_getBlockByNumber,
if_hash=RPC.eth_getBlockByHash,
if_number=RPC.eth_getBlockByNumber,
),
mungers=[BaseEth.get_block_munger],
)

async def get_block(
Expand Down Expand Up @@ -660,9 +660,9 @@ async def get_uncle_count(self, block_identifier: BlockIdentifier) -> int:

# eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter

_get_filter_changes: Method[Callable[[HexStr], Awaitable[List[LogReceipt]]]] = (
Method(RPC.eth_getFilterChanges, mungers=[default_root_munger])
)
_get_filter_changes: Method[
Callable[[HexStr], Awaitable[List[LogReceipt]]]
] = Method(RPC.eth_getFilterChanges, mungers=[default_root_munger])

async def get_filter_changes(self, filter_id: HexStr) -> List[LogReceipt]:
return await self._get_filter_changes(filter_id)
Expand Down Expand Up @@ -740,12 +740,14 @@ async def unsubscribe(self, subscription_id: HexStr) -> bool:
# -- contract methods -- #

@overload
def contract(self, address: None = None, **kwargs: Any) -> Type[AsyncContract]: ...
def contract(self, address: None = None, **kwargs: Any) -> Type[AsyncContract]: # type: ignore # noqa: E501
...

@overload
def contract(
self, address: Union[Address, ChecksumAddress, ENS], **kwargs: Any
) -> AsyncContract: ...
) -> AsyncContract:
...

def contract(
self,
Expand Down
24 changes: 13 additions & 11 deletions web3/eth/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,15 +619,15 @@ def modify_transaction(

# eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter

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,
if_new_filter=RPC.eth_newFilter,
),
mungers=[BaseEth.filter_munger],
)
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,
if_new_filter=RPC.eth_newFilter,
),
mungers=[BaseEth.filter_munger],
)

# eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter
Expand Down Expand Up @@ -665,12 +665,14 @@ def modify_transaction(
)

@overload
def contract(self, address: None = None, **kwargs: Any) -> Type[Contract]: ...
def contract(self, address: None = None, **kwargs: Any) -> Type[Contract]: # type: ignore # noqa: E501
...

@overload
def contract(
self, address: Union[Address, ChecksumAddress, ENS], **kwargs: Any
) -> Contract: ...
) -> Contract:
...

def contract(
self,
Expand Down
8 changes: 6 additions & 2 deletions web3/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def _set_mungers(
return (
mungers
if mungers
else [default_munger] if is_property else [default_root_munger]
else [default_munger]
if is_property
else [default_root_munger]
)


Expand Down Expand Up @@ -175,7 +177,9 @@ def input_munger(self, module: "Module", args: Any, kwargs: Any) -> List[Any]:
lambda args, munger: munger(module, *args, **kwargs), self.mungers, args
)

def process_params(self, module: "Module", *args: Any, **kwargs: Any) -> Tuple[
def process_params(
self, module: "Module", *args: Any, **kwargs: Any
) -> Tuple[
Tuple[Union[RPCEndpoint, Callable[..., RPCEndpoint]], Tuple[Any, ...]],
Tuple[
Union[TReturn, Dict[str, Callable[..., Any]]],
Expand Down
4 changes: 2 additions & 2 deletions web3/middleware/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse:

AVG_BLOCK_TIME_KEY: Literal["avg_block_time"] = "avg_block_time"
AVG_BLOCK_SAMPLE_SIZE_KEY: Literal["avg_block_sample_size"] = "avg_block_sample_size"
AVG_BLOCK_TIME_UPDATED_AT_KEY: Literal["avg_block_time_updated_at"] = (
AVG_BLOCK_TIME_UPDATED_AT_KEY: Literal[
"avg_block_time_updated_at"
)
] = "avg_block_time_updated_at"


def _is_latest_block_number_request(method: RPCEndpoint, params: Any) -> bool:
Expand Down

0 comments on commit b51ae27

Please sign in to comment.