Skip to content

Commit

Permalink
Rename ModuleV2 to Module
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Apr 28, 2021
1 parent e8bb5e6 commit 910f625
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 51 deletions.
1 change: 1 addition & 0 deletions newsfragments/1964.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rename ModuleV2 to Module, since Module was removed in #1805
4 changes: 2 additions & 2 deletions tests/core/method-class/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
default_root_munger,
)
from web3.module import (
ModuleV2,
Module,
apply_result_formatters,
)

Expand Down Expand Up @@ -254,7 +254,7 @@ def formatter(params):
return compose(formatter)


class FakeModule(ModuleV2):
class FakeModule(Module):
method = Method(
'eth_method',
mungers=[keywords],
Expand Down
4 changes: 2 additions & 2 deletions tests/core/method-class/test_result_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
construct_result_generator_middleware,
)
from web3.module import (
ModuleV2,
Module,
)
from web3.providers import (
BaseProvider,
Expand All @@ -35,7 +35,7 @@ def make_request(method, params):
})


class ModuleForTest(ModuleV2):
class ModuleForTest(Module):
method = Method(
'method_for_test',
result_formatters=result_formatter)
Expand Down
10 changes: 5 additions & 5 deletions tests/core/utilities/test_attach_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
ValidationError,
)
from web3.module import (
ModuleV2,
Module,
)
from web3.providers.eth_tester import (
EthereumTesterProvider,
)


class MockEth(ModuleV2):
class MockEth(Module):
def block_number(self):
return 42


class MockGeth(ModuleV2):
class MockGeth(Module):
pass


class MockGethAdmin(ModuleV2):
class MockGethAdmin(Module):
def start_ws(self):
return True


class MockGethPersonal(ModuleV2):
class MockGethPersonal(Module):
def unlock_account(self):
return True

Expand Down
4 changes: 2 additions & 2 deletions web3/_utils/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
default_root_munger,
)
from web3.module import (
ModuleV2,
Module,
)
from web3.types import (
EnodeURI,
Expand All @@ -26,7 +26,7 @@


def admin_start_params_munger(
module: ModuleV2, host: str = 'localhost', port: int = 8546, cors: str = '',
module: Module, host: str = 'localhost', port: int = 8546, cors: str = '',
apis: str = 'eth,net,web3'
) -> Tuple[str, int, str, str]:
return (host, port, cors, apis)
Expand Down
6 changes: 3 additions & 3 deletions web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

if TYPE_CHECKING:
from web3 import Web3 # noqa: F401
from web3.module import ModuleV2 # noqa: F401
from web3.module import Module # noqa: F401
from web3.eth import Eth # noqa: F401


Expand Down Expand Up @@ -656,7 +656,7 @@ def filter_wrapper(
@to_tuple
def apply_module_to_formatters(
formatters: Tuple[Callable[..., TReturn]],
module: "ModuleV2",
module: "Module",
method_name: Union[RPCEndpoint, Callable[..., RPCEndpoint]],
) -> Iterable[Callable[..., TReturn]]:
for f in formatters:
Expand All @@ -665,7 +665,7 @@ def apply_module_to_formatters(

def get_result_formatters(
method_name: Union[RPCEndpoint, Callable[..., RPCEndpoint]],
module: "ModuleV2",
module: "Module",
) -> Dict[str, Callable[..., Any]]:
formatters = combine_formatters(
(PYTHONIC_RESULT_FORMATTERS,),
Expand Down
6 changes: 3 additions & 3 deletions web3/_utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

if TYPE_CHECKING:
from web3 import Web3 # noqa: F401
from web3.module import ModuleV2 # noqa: F401
from web3.module import Module # noqa: F401


def attach_modules(
parent_module: Union["Web3", "ModuleV2"],
parent_module: Union["Web3", "Module"],
module_definitions: Dict[str, Sequence[Any]],
w3: Optional[Union["Web3", "ModuleV2"]] = None
w3: Optional[Union["Web3", "Module"]] = None
) -> None:
for module_name, module_info in module_definitions.items():
module_class = module_info[0]
Expand Down
4 changes: 2 additions & 2 deletions web3/beacon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import requests

from web3.module import (
ModuleV2,
Module,
)


class Beacon(ModuleV2):
class Beacon(Module):
def __init__(
self,
base_url: str,
Expand Down
4 changes: 2 additions & 2 deletions web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
default_root_munger,
)
from web3.module import (
ModuleV2,
Module,
)
from web3.types import (
ENS,
Expand All @@ -104,7 +104,7 @@
)


class Eth(ModuleV2):
class Eth(Module):
account = Account()
_default_account: Union[ChecksumAddress, Empty] = empty
_default_block: BlockIdentifier = "latest"
Expand Down
12 changes: 6 additions & 6 deletions web3/geth.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
status,
)
from web3.module import (
ModuleV2,
Module,
)


class GethPersonal(ModuleV2):
class GethPersonal(Module):
"""
https://github.com/ethereum/go-ethereum/wiki/management-apis#personal
"""
Expand All @@ -85,7 +85,7 @@ class GethPersonal(ModuleV2):
unlockAccount = unlockAccount


class GethTxPool(ModuleV2):
class GethTxPool(Module):
"""
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#txpool
"""
Expand All @@ -94,7 +94,7 @@ class GethTxPool(ModuleV2):
status = status


class GethAdmin(ModuleV2):
class GethAdmin(Module):
"""
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#admin
"""
Expand All @@ -115,7 +115,7 @@ class GethAdmin(ModuleV2):
stopWS = stopWS


class GethMiner(ModuleV2):
class GethMiner(Module):
"""
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#miner
"""
Expand All @@ -136,6 +136,6 @@ class GethMiner(ModuleV2):
stopAutoDag = stopAutoDag


class Geth(ModuleV2):
class Geth(Module):
personal: GethPersonal
admin: GethAdmin
18 changes: 9 additions & 9 deletions web3/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

if TYPE_CHECKING:
from web3 import Web3 # noqa: F401
from web3.module import ModuleV2 # noqa: F401
from web3.module import Module # noqa: F401

Munger = Callable[..., Any]

Expand All @@ -59,14 +59,14 @@ def inner(args: Any) -> TReturn:
return inner


def default_munger(module: "ModuleV2", *args: Any, **kwargs: Any) -> Tuple[()]:
def default_munger(module: "Module", *args: Any, **kwargs: Any) -> Tuple[()]:
if not args and not kwargs:
return ()
else:
raise TypeError("Parameters passed to method without parameter mungers defined.")


def default_root_munger(module: "ModuleV2", *args: Any) -> List[Any]:
def default_root_munger(module: "Module", *args: Any) -> List[Any]:
return [*args]


Expand Down Expand Up @@ -129,8 +129,8 @@ def __init__(
self.error_formatters = get_error_formatters
self.method_choice_depends_on_args = method_choice_depends_on_args

def __get__(self, obj: Optional["ModuleV2"] = None,
obj_type: Optional[Type["ModuleV2"]] = None) -> TFunc:
def __get__(self, obj: Optional["Module"] = None,
obj_type: Optional[Type["Module"]] = None) -> TFunc:
if obj is None:
raise TypeError(
"Direct calls to methods are not supported. "
Expand All @@ -149,7 +149,7 @@ def method_selector_fn(self) -> Callable[..., Union[RPCEndpoint, Callable[..., R
raise ValueError("``json_rpc_method`` config invalid. May be a string or function")

def input_munger(
self, module: "ModuleV2", args: Any, kwargs: Any
self, module: "Module", args: Any, kwargs: Any
) -> List[Any]:
# This function takes the "root_munger" - the first munger in
# the list of mungers) and then pipes the return value of the
Expand All @@ -168,7 +168,7 @@ def input_munger(
return munged_inputs

def process_params(
self, module: "ModuleV2", *args: Any, **kwargs: Any
self, module: "Module", *args: Any, **kwargs: Any
) -> Tuple[Tuple[Union[RPCEndpoint, Callable[..., Any]], Any], Tuple[Any, Any]]:
params = self.input_munger(module, args, kwargs)

Expand Down Expand Up @@ -202,8 +202,8 @@ def __init__(self, method: Method[Callable[..., Any]], old_name: str, new_name:
self.old_name = old_name
self.new_name = new_name

def __get__(self, obj: Optional["ModuleV2"] = None,
obj_type: Optional[Type["ModuleV2"]] = None) -> Any:
def __get__(self, obj: Optional["Module"] = None,
obj_type: Optional[Type["Module"]] = None) -> Any:
warnings.warn(
f"{self.old_name} is deprecated in favor of {self.new_name}",
category=DeprecationWarning,
Expand Down
6 changes: 3 additions & 3 deletions web3/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def apply_result_formatters(

@curry
def retrieve_blocking_method_call_fn(
w3: "Web3", module: "ModuleV2", method: Method[Callable[..., TReturn]]
w3: "Web3", module: "Module", method: Method[Callable[..., TReturn]]
) -> Callable[..., Union[TReturn, LogFilter]]:
def caller(*args: Any, **kwargs: Any) -> Union[TReturn, LogFilter]:
try:
Expand All @@ -61,7 +61,7 @@ def caller(*args: Any, **kwargs: Any) -> Union[TReturn, LogFilter]:

@curry
def retrieve_async_method_call_fn(
w3: "Web3", module: "ModuleV2", method: Method[Callable[..., Any]]
w3: "Web3", module: "Module", method: Method[Callable[..., Any]]
) -> Callable[..., Coroutine[Any, Any, RPCResponse]]:
async def caller(*args: Any, **kwargs: Any) -> RPCResponse:
(method_str, params), response_formatters = method.process_params(module, *args, **kwargs)
Expand All @@ -75,7 +75,7 @@ async def caller(*args: Any, **kwargs: Any) -> RPCResponse:
# Only the calling functions need access to the request methods.
# Any "re-entrant" shinanigans can go in the middlewares, which do
# have web3 access.
class ModuleV2:
class Module:
is_async = False

def __init__(self, web3: "Web3") -> None:
Expand Down
4 changes: 2 additions & 2 deletions web3/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
version,
)
from web3.module import (
ModuleV2,
Module,
)


class Net(ModuleV2):
class Net(Module):
"""
https://github.com/ethereum/wiki/wiki/JSON-RPC
"""
Expand Down
6 changes: 3 additions & 3 deletions web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
default_root_munger,
)
from web3.module import (
ModuleV2,
Module,
)
from web3.types import (
ENS,
Expand All @@ -63,7 +63,7 @@
)


class ParityPersonal(ModuleV2):
class ParityPersonal(Module):
"""
https://wiki.parity.io/JSONRPC-personal-module
"""
Expand All @@ -85,7 +85,7 @@ class ParityPersonal(ModuleV2):
unlockAccount = unlockAccount


class Parity(ModuleV2):
class Parity(Module):
"""
https://paritytech.github.io/wiki/JSONRPC-parity-module
"""
Expand Down
4 changes: 2 additions & 2 deletions web3/pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
PMError,
)
from web3.module import (
ModuleV2,
Module,
)
from web3.types import (
ENS,
Expand Down Expand Up @@ -312,7 +312,7 @@ def deploy_new_instance(cls, w3: Web3) -> 'SimpleRegistry':
return cls(tx_receipt["contractAddress"], w3)


class PM(ModuleV2):
class PM(Module):
"""
The PM module will work with any subclass of ``ERC1319Registry``, tailored to a particular
implementation of `ERC1319 <https://github.com/ethereum/EIPs/issues/1319>`__, set as
Expand Down
4 changes: 2 additions & 2 deletions web3/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
RPC,
)
from web3.module import (
ModuleV2,
Module,
)


class Testing(ModuleV2):
class Testing(Module):
def timeTravel(self, timestamp: int) -> None:
return self.web3.manager.request_blocking(RPC.testing_timeTravel, [timestamp])

Expand Down
Loading

0 comments on commit 910f625

Please sign in to comment.