We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Deprecate `miner` namespace support and tests

### What was wrong?

Geth removed support for their `miner` API since it's no longer needed after The Merge ™️ . See: https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-miner


### How can it be fixed?

Add deprecation warnings to the methods within the miner namespace, and change the tests to check for the deprecation warnings. We can then either remove the methods as Geth stops supporting these, or wait until v7 to remove.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `web3/method.py`
Content:
```
1 import functools
2 from typing import (
3     TYPE_CHECKING,
4     Any,
5     Callable,
6     Dict,
7     Generic,
8     List,
9     Optional,
10     Sequence,
11     Tuple,
12     Type,
13     TypeVar,
14     Union,
15 )
16 import warnings
17 
18 from eth_utils.curried import (
19     to_tuple,
20 )
21 from eth_utils.toolz import (
22     pipe,
23 )
24 
25 from web3._utils.method_formatters import (
26     get_error_formatters,
27     get_null_result_formatters,
28     get_request_formatters,
29     get_result_formatters,
30 )
31 from web3._utils.rpc_abi import (
32     RPC,
33 )
34 from web3.exceptions import (
35     Web3ValidationError,
36 )
37 from web3.types import (
38     RPCEndpoint,
39     TReturn,
40 )
41 
42 if TYPE_CHECKING:
43     from web3 import Web3  # noqa: F401
44     from web3.module import Module  # noqa: F401
45 
46 
47 Munger = Callable[..., Any]
48 
49 
50 @to_tuple
51 def _apply_request_formatters(
52     params: Any, request_formatters: Dict[RPCEndpoint, Callable[..., TReturn]]
53 ) -> Tuple[Any, ...]:
54     if request_formatters:
55         formatted_params = pipe(params, request_formatters)
56         return formatted_params
57     return params
58 
59 
60 def _set_mungers(
61     mungers: Optional[Sequence[Munger]], is_property: bool
62 ) -> Sequence[Any]:
63     if is_property and mungers:
64         raise Web3ValidationError("Mungers cannot be used with a property.")
65 
66     return (
67         mungers
68         if mungers
69         else [default_munger] if is_property else [default_root_munger]
70     )
71 
72 
73 def default_munger(_module: "Module", *args: Any, **kwargs: Any) -> Tuple[()]:
74     if args or kwargs:
75         raise Web3ValidationError("Parameters cannot be passed to a property.")
76     return ()
77 
78 
79 def default_root_munger(_module: "Module", *args: Any) -> List[Any]:
80     return [*args]
81 
82 
83 TFunc = TypeVar("TFunc", bound=Callable[..., Any])
84 
85 
86 class Method(Generic[TFunc]):
87     """Method object for web3 module methods
88 
89     Calls to the Method go through these steps:
90 
91     1. input munging - includes normalization, parameter checking, early parameter
92     formatting. Any processing on the input parameters that need to happen before
93     json_rpc method string selection occurs.
94 
95             A note about mungers: The first (root) munger should reflect the desired
96         api function arguments. In other words, if the api function wants to
97         behave as: `get_balance(account, block_identifier=None)`, the root munger
98         should accept these same arguments, with the addition of the module as
99         the first argument e.g.:
100 
101         ```
102         def get_balance_root_munger(module, account, block_identifier=None):
103             if block_identifier is None:
104                 block_identifier = DEFAULT_BLOCK
105             return module, [account, block_identifier]
106         ```
107 
108         all mungers should return an argument list.
109 
110         if no munger is provided, a default munger expecting no method arguments
111         will be used.
112 
113     2. method selection - The json_rpc_method argument can be method string or a
114     function that returns a method string. If a callable is provided the processed
115     method inputs are passed to the method selection function, and the returned
116     method string is used.
117 
118     3. request and response formatters are set - formatters are retrieved
119     using the json rpc method string.
120 
121     4. After the parameter processing from steps 1-3 the request is made using
122     the calling function returned by the module attribute ``retrieve_caller_fn``
123     and the response formatters are applied to the output.
124     """
125 
126     def __init__(
127         self,
128         json_rpc_method: Optional[RPCEndpoint] = None,
129         mungers: Optional[Sequence[Munger]] = None,
130         request_formatters: Optional[Callable[..., TReturn]] = None,
131         result_formatters: Optional[Callable[..., TReturn]] = None,
132         null_result_formatters: Optional[Callable[..., TReturn]] = None,
133         method_choice_depends_on_args: Optional[Callable[..., RPCEndpoint]] = None,
134         is_property: bool = False,
135     ):
136         self.json_rpc_method = json_rpc_method
137         self.mungers = _set_mungers(mungers, is_property)
138         self.request_formatters = request_formatters or get_request_formatters
139         self.result_formatters = result_formatters or get_result_formatters
140         self.null_result_formatters = (
141             null_result_formatters or get_null_result_formatters
142         )
143         self.method_choice_depends_on_args = method_choice_depends_on_args
144         self.is_property = is_property
145 
146     def __get__(
147         self, obj: Optional["Module"] = None, obj_type: Optional[Type["Module"]] = None
148     ) -> TFunc:
149         if obj is None:
150             raise TypeError(
151                 "Direct calls to methods are not supported. "
152                 "Methods must be called from an module instance, "
153                 "usually attached to a web3 instance."
154             )
155         return obj.retrieve_caller_fn(self)
156 
157     @property
158     def method_selector_fn(
159         self,
160     ) -> Callable[..., Union[RPCEndpoint, Callable[..., RPCEndpoint]]]:
161         """Gets the method selector from the config."""
162         if callable(self.json_rpc_method):
163             return self.json_rpc_method
164         elif isinstance(self.json_rpc_method, (str,)):
165             return lambda *_: self.json_rpc_method
166         raise ValueError(
167             "``json_rpc_method`` config invalid.  May be a string or function"
168         )
169 
170     def input_munger(self, module: "Module", args: Any, kwargs: Any) -> List[Any]:
171         # This function takes the input parameters and munges them.
172         # See the test_process_params test in ``tests/core/method-class/test_method.py``
173         # for an example with multiple mungers.
174         return functools.reduce(
175             lambda args, munger: munger(module, *args, **kwargs), self.mungers, args
176         )
177 
178     def process_params(self, module: "Module", *args: Any, **kwargs: Any) -> Tuple[
179         Tuple[Union[RPCEndpoint, Callable[..., RPCEndpoint]], Tuple[Any, ...]],
180         Tuple[
181             Union[TReturn, Dict[str, Callable[..., Any]]],
182             Callable[..., Any],
183             Union[TReturn, Callable[..., Any]],
184         ],
185     ]:
186         params = self.input_munger(module, args, kwargs)
187 
188         if self.method_choice_depends_on_args:
189             # If the method choice depends on the args that get passed in,
190             # the first parameter determines which method needs to be called
191             self.json_rpc_method = self.method_choice_depends_on_args(value=params[0])
192 
193             pending_or_latest_filter_methods = [
194                 RPC.eth_newPendingTransactionFilter,
195                 RPC.eth_newBlockFilter,
196             ]
197             if self.json_rpc_method in pending_or_latest_filter_methods:
198                 # For pending or latest filter methods, use params to determine
199                 # which method to call, but don't pass them through with the request
200                 params = []
201 
202         method = self.method_selector_fn()
203         response_formatters = (
204             self.result_formatters(method, module),
205             get_error_formatters(method),
206             self.null_result_formatters(method),
207         )
208         request = (
209             method,
210             _apply_request_formatters(params, self.request_formatters(method)),
211         )
212         return request, response_formatters
213 
214 
215 class DeprecatedMethod:
216     def __init__(
217         self, method: Method[Callable[..., Any]], old_name: str, new_name: str
218     ) -> None:
219         self.method = method
220         self.old_name = old_name
221         self.new_name = new_name
222 
223     def __get__(
224         self, obj: Optional["Module"] = None, obj_type: Optional[Type["Module"]] = None
225     ) -> Any:
226         warnings.warn(
227             f"{self.old_name} is deprecated in favor of {self.new_name}",
228             category=DeprecationWarning,
229         )
230         return self.method.__get__(obj, obj_type)
231
```

Path: `web3/_utils/miner.py`
Content:
```
1 from typing import (
2     Callable,
3 )
4 
5 from eth_typing import (
6     ChecksumAddress,
7 )
8 
9 from web3._utils.rpc_abi import (
10     RPC,
11 )
12 from web3.method import (
13     Method,
14     default_root_munger,
15 )
16 from web3.types import (
17     BlockNumber,
18     Wei,
19 )
20 
21 make_dag: Method[Callable[[BlockNumber], bool]] = Method(
22     RPC.miner_makeDag,
23     mungers=[default_root_munger],
24 )
25 
26 
27 set_extra: Method[Callable[[str], bool]] = Method(
28     RPC.miner_setExtra,
29     mungers=[default_root_munger],
30 )
31 
32 
33 set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(
34     RPC.miner_setEtherbase,
35     mungers=[default_root_munger],
36 )
37 
38 
39 set_gas_price: Method[Callable[[Wei], bool]] = Method(
40     RPC.miner_setGasPrice,
41     mungers=[default_root_munger],
42 )
43 
44 
45 start: Method[Callable[[int], bool]] = Method(
46     RPC.miner_start,
47     mungers=[default_root_munger],
48 )
49 
50 
51 stop: Method[Callable[[], bool]] = Method(
52     RPC.miner_stop,
53     is_property=True,
54 )
55 
56 
57 start_auto_dag: Method[Callable[[], bool]] = Method(
58     RPC.miner_startAutoDag,
59     is_property=True,
60 )
61 
62 
63 stop_auto_dag: Method[Callable[[], bool]] = Method(
64     RPC.miner_stopAutoDag,
65     is_property=True,
66 )
67
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/web3/_utils/miner.py b/web3/_utils/miner.py
--- a/web3/_utils/miner.py
+++ b/web3/_utils/miner.py
@@ -10,6 +10,7 @@
     RPC,
 )
 from web3.method import (
+    DeprecatedMethod,
     Method,
     default_root_munger,
 )
@@ -18,49 +19,74 @@
     Wei,
 )
 
-make_dag: Method[Callable[[BlockNumber], bool]] = Method(
+#
+# The Geth client deprecated the miner namespace.
+#
+
+_make_dag: Method[Callable[[BlockNumber], bool]] = Method(
     RPC.miner_makeDag,
     mungers=[default_root_munger],
 )
 
+make_dag = DeprecatedMethod(
+    _make_dag, "make_dag", msg="All mining methods have been deprecated"
+)
 
-set_extra: Method[Callable[[str], bool]] = Method(
+_set_extra: Method[Callable[[str], bool]] = Method(
     RPC.miner_setExtra,
     mungers=[default_root_munger],
 )
 
+set_extra = DeprecatedMethod(
+    _set_extra, "set_extra", msg="All mining methods have been deprecated"
+)
 
-set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(
+_set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(
     RPC.miner_setEtherbase,
     mungers=[default_root_munger],
 )
 
+set_etherbase = DeprecatedMethod(
+    _set_etherbase, "set_etherbase", msg="All mining methods have been deprecated"
+)
 
-set_gas_price: Method[Callable[[Wei], bool]] = Method(
+_set_gas_price: Method[Callable[[Wei], bool]] = Method(
     RPC.miner_setGasPrice,
     mungers=[default_root_munger],
 )
 
+set_gas_price = DeprecatedMethod(
+    _set_gas_price, "set_gas_price", msg="All mining methods have been deprecated"
+)
 
-start: Method[Callable[[int], bool]] = Method(
+_start: Method[Callable[[int], bool]] = Method(
     RPC.miner_start,
     mungers=[default_root_munger],
 )
 
+start = DeprecatedMethod(_start, "start", msg="All mining methods have been deprecated")
 
-stop: Method[Callable[[], bool]] = Method(
+_stop: Method[Callable[[], bool]] = Method(
     RPC.miner_stop,
     is_property=True,
 )
 
+stop = DeprecatedMethod(_stop, "stop", msg="All mining methods have been deprecated")
 
-start_auto_dag: Method[Callable[[], bool]] = Method(
+_start_auto_dag: Method[Callable[[], bool]] = Method(
     RPC.miner_startAutoDag,
     is_property=True,
 )
 
+start_auto_dag = DeprecatedMethod(
+    _start_auto_dag, "start_auto_dag", msg="All mining methods have been deprecated"
+)
 
-stop_auto_dag: Method[Callable[[], bool]] = Method(
+_stop_auto_dag: Method[Callable[[], bool]] = Method(
     RPC.miner_stopAutoDag,
     is_property=True,
 )
+
+stop_auto_dag = DeprecatedMethod(
+    _stop_auto_dag, "stop_auto_dag", msg="All mining methods have been deprecated"
+)
diff --git a/web3/method.py b/web3/method.py
--- a/web3/method.py
+++ b/web3/method.py
@@ -214,17 +214,26 @@
 
 class DeprecatedMethod:
     def __init__(
-        self, method: Method[Callable[..., Any]], old_name: str, new_name: str
+        self,
+        method: Method[Callable[..., Any]],
+        old_name: str,
+        new_name: Optional[str] = None,
+        msg: Optional[str] = None,
     ) -> None:
         self.method = method
         self.old_name = old_name
         self.new_name = new_name
+        self.msg = msg
 
     def __get__(
         self, obj: Optional["Module"] = None, obj_type: Optional[Type["Module"]] = None
     ) -> Any:
+        message = f"{self.old_name} is deprecated in favor of {self.new_name}"
+        if self.msg is not None:
+            message = self.msg
+
         warnings.warn(
-            f"{self.old_name} is deprecated in favor of {self.new_name}",
+            message,
             category=DeprecationWarning,
         )
         return self.method.__get__(obj, obj_type)

{"golden_diff": "diff --git a/web3/_utils/miner.py b/web3/_utils/miner.py\n--- a/web3/_utils/miner.py\n+++ b/web3/_utils/miner.py\n@@ -10,6 +10,7 @@\n     RPC,\n )\n from web3.method import (\n+    DeprecatedMethod,\n     Method,\n     default_root_munger,\n )\n@@ -18,49 +19,74 @@\n     Wei,\n )\n \n-make_dag: Method[Callable[[BlockNumber], bool]] = Method(\n+#\n+# The Geth client deprecated the miner namespace.\n+#\n+\n+_make_dag: Method[Callable[[BlockNumber], bool]] = Method(\n     RPC.miner_makeDag,\n     mungers=[default_root_munger],\n )\n \n+make_dag = DeprecatedMethod(\n+    _make_dag, \"make_dag\", msg=\"All mining methods have been deprecated\"\n+)\n \n-set_extra: Method[Callable[[str], bool]] = Method(\n+_set_extra: Method[Callable[[str], bool]] = Method(\n     RPC.miner_setExtra,\n     mungers=[default_root_munger],\n )\n \n+set_extra = DeprecatedMethod(\n+    _set_extra, \"set_extra\", msg=\"All mining methods have been deprecated\"\n+)\n \n-set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(\n+_set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(\n     RPC.miner_setEtherbase,\n     mungers=[default_root_munger],\n )\n \n+set_etherbase = DeprecatedMethod(\n+    _set_etherbase, \"set_etherbase\", msg=\"All mining methods have been deprecated\"\n+)\n \n-set_gas_price: Method[Callable[[Wei], bool]] = Method(\n+_set_gas_price: Method[Callable[[Wei], bool]] = Method(\n     RPC.miner_setGasPrice,\n     mungers=[default_root_munger],\n )\n \n+set_gas_price = DeprecatedMethod(\n+    _set_gas_price, \"set_gas_price\", msg=\"All mining methods have been deprecated\"\n+)\n \n-start: Method[Callable[[int], bool]] = Method(\n+_start: Method[Callable[[int], bool]] = Method(\n     RPC.miner_start,\n     mungers=[default_root_munger],\n )\n \n+start = DeprecatedMethod(_start, \"start\", msg=\"All mining methods have been deprecated\")\n \n-stop: Method[Callable[[], bool]] = Method(\n+_stop: Method[Callable[[], bool]] = Method(\n     RPC.miner_stop,\n     is_property=True,\n )\n \n+stop = DeprecatedMethod(_stop, \"stop\", msg=\"All mining methods have been deprecated\")\n \n-start_auto_dag: Method[Callable[[], bool]] = Method(\n+_start_auto_dag: Method[Callable[[], bool]] = Method(\n     RPC.miner_startAutoDag,\n     is_property=True,\n )\n \n+start_auto_dag = DeprecatedMethod(\n+    _start_auto_dag, \"start_auto_dag\", msg=\"All mining methods have been deprecated\"\n+)\n \n-stop_auto_dag: Method[Callable[[], bool]] = Method(\n+_stop_auto_dag: Method[Callable[[], bool]] = Method(\n     RPC.miner_stopAutoDag,\n     is_property=True,\n )\n+\n+stop_auto_dag = DeprecatedMethod(\n+    _stop_auto_dag, \"stop_auto_dag\", msg=\"All mining methods have been deprecated\"\n+)\ndiff --git a/web3/method.py b/web3/method.py\n--- a/web3/method.py\n+++ b/web3/method.py\n@@ -214,17 +214,26 @@\n \n class DeprecatedMethod:\n     def __init__(\n-        self, method: Method[Callable[..., Any]], old_name: str, new_name: str\n+        self,\n+        method: Method[Callable[..., Any]],\n+        old_name: str,\n+        new_name: Optional[str] = None,\n+        msg: Optional[str] = None,\n     ) -> None:\n         self.method = method\n         self.old_name = old_name\n         self.new_name = new_name\n+        self.msg = msg\n \n     def __get__(\n         self, obj: Optional[\"Module\"] = None, obj_type: Optional[Type[\"Module\"]] = None\n     ) -> Any:\n+        message = f\"{self.old_name} is deprecated in favor of {self.new_name}\"\n+        if self.msg is not None:\n+            message = self.msg\n+\n         warnings.warn(\n-            f\"{self.old_name} is deprecated in favor of {self.new_name}\",\n+            message,\n             category=DeprecationWarning,\n         )\n         return self.method.__get__(obj, obj_type)\n", "issue": "Deprecate `miner` namespace support and tests\n\r\n### What was wrong?\r\n\r\nGeth removed support for their `miner` API since it's no longer needed after The Merge \u2122\ufe0f . See: https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-miner\r\n\r\n\r\n### How can it be fixed?\r\n\r\nAdd deprecation warnings to the methods within the miner namespace, and change the tests to check for the deprecation warnings. We can then either remove the methods as Geth stops supporting these, or wait until v7 to remove.\r\n\n", "before_files": [{"content": "import functools\nfrom typing import (\n    TYPE_CHECKING,\n    Any,\n    Callable,\n    Dict,\n    Generic,\n    List,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    TypeVar,\n    Union,\n)\nimport warnings\n\nfrom eth_utils.curried import (\n    to_tuple,\n)\nfrom eth_utils.toolz import (\n    pipe,\n)\n\nfrom web3._utils.method_formatters import (\n    get_error_formatters,\n    get_null_result_formatters,\n    get_request_formatters,\n    get_result_formatters,\n)\nfrom web3._utils.rpc_abi import (\n    RPC,\n)\nfrom web3.exceptions import (\n    Web3ValidationError,\n)\nfrom web3.types import (\n    RPCEndpoint,\n    TReturn,\n)\n\nif TYPE_CHECKING:\n    from web3 import Web3  # noqa: F401\n    from web3.module import Module  # noqa: F401\n\n\nMunger = Callable[..., Any]\n\n\n@to_tuple\ndef _apply_request_formatters(\n    params: Any, request_formatters: Dict[RPCEndpoint, Callable[..., TReturn]]\n) -> Tuple[Any, ...]:\n    if request_formatters:\n        formatted_params = pipe(params, request_formatters)\n        return formatted_params\n    return params\n\n\ndef _set_mungers(\n    mungers: Optional[Sequence[Munger]], is_property: bool\n) -> Sequence[Any]:\n    if is_property and mungers:\n        raise Web3ValidationError(\"Mungers cannot be used with a property.\")\n\n    return (\n        mungers\n        if mungers\n        else [default_munger] if is_property else [default_root_munger]\n    )\n\n\ndef default_munger(_module: \"Module\", *args: Any, **kwargs: Any) -> Tuple[()]:\n    if args or kwargs:\n        raise Web3ValidationError(\"Parameters cannot be passed to a property.\")\n    return ()\n\n\ndef default_root_munger(_module: \"Module\", *args: Any) -> List[Any]:\n    return [*args]\n\n\nTFunc = TypeVar(\"TFunc\", bound=Callable[..., Any])\n\n\nclass Method(Generic[TFunc]):\n    \"\"\"Method object for web3 module methods\n\n    Calls to the Method go through these steps:\n\n    1. input munging - includes normalization, parameter checking, early parameter\n    formatting. Any processing on the input parameters that need to happen before\n    json_rpc method string selection occurs.\n\n            A note about mungers: The first (root) munger should reflect the desired\n        api function arguments. In other words, if the api function wants to\n        behave as: `get_balance(account, block_identifier=None)`, the root munger\n        should accept these same arguments, with the addition of the module as\n        the first argument e.g.:\n\n        ```\n        def get_balance_root_munger(module, account, block_identifier=None):\n            if block_identifier is None:\n                block_identifier = DEFAULT_BLOCK\n            return module, [account, block_identifier]\n        ```\n\n        all mungers should return an argument list.\n\n        if no munger is provided, a default munger expecting no method arguments\n        will be used.\n\n    2. method selection - The json_rpc_method argument can be method string or a\n    function that returns a method string. If a callable is provided the processed\n    method inputs are passed to the method selection function, and the returned\n    method string is used.\n\n    3. request and response formatters are set - formatters are retrieved\n    using the json rpc method string.\n\n    4. After the parameter processing from steps 1-3 the request is made using\n    the calling function returned by the module attribute ``retrieve_caller_fn``\n    and the response formatters are applied to the output.\n    \"\"\"\n\n    def __init__(\n        self,\n        json_rpc_method: Optional[RPCEndpoint] = None,\n        mungers: Optional[Sequence[Munger]] = None,\n        request_formatters: Optional[Callable[..., TReturn]] = None,\n        result_formatters: Optional[Callable[..., TReturn]] = None,\n        null_result_formatters: Optional[Callable[..., TReturn]] = None,\n        method_choice_depends_on_args: Optional[Callable[..., RPCEndpoint]] = None,\n        is_property: bool = False,\n    ):\n        self.json_rpc_method = json_rpc_method\n        self.mungers = _set_mungers(mungers, is_property)\n        self.request_formatters = request_formatters or get_request_formatters\n        self.result_formatters = result_formatters or get_result_formatters\n        self.null_result_formatters = (\n            null_result_formatters or get_null_result_formatters\n        )\n        self.method_choice_depends_on_args = method_choice_depends_on_args\n        self.is_property = is_property\n\n    def __get__(\n        self, obj: Optional[\"Module\"] = None, obj_type: Optional[Type[\"Module\"]] = None\n    ) -> TFunc:\n        if obj is None:\n            raise TypeError(\n                \"Direct calls to methods are not supported. \"\n                \"Methods must be called from an module instance, \"\n                \"usually attached to a web3 instance.\"\n            )\n        return obj.retrieve_caller_fn(self)\n\n    @property\n    def method_selector_fn(\n        self,\n    ) -> Callable[..., Union[RPCEndpoint, Callable[..., RPCEndpoint]]]:\n        \"\"\"Gets the method selector from the config.\"\"\"\n        if callable(self.json_rpc_method):\n            return self.json_rpc_method\n        elif isinstance(self.json_rpc_method, (str,)):\n            return lambda *_: self.json_rpc_method\n        raise ValueError(\n            \"``json_rpc_method`` config invalid.  May be a string or function\"\n        )\n\n    def input_munger(self, module: \"Module\", args: Any, kwargs: Any) -> List[Any]:\n        # This function takes the input parameters and munges them.\n        # See the test_process_params test in ``tests/core/method-class/test_method.py``\n        # for an example with multiple mungers.\n        return functools.reduce(\n            lambda args, munger: munger(module, *args, **kwargs), self.mungers, args\n        )\n\n    def process_params(self, module: \"Module\", *args: Any, **kwargs: Any) -> Tuple[\n        Tuple[Union[RPCEndpoint, Callable[..., RPCEndpoint]], Tuple[Any, ...]],\n        Tuple[\n            Union[TReturn, Dict[str, Callable[..., Any]]],\n            Callable[..., Any],\n            Union[TReturn, Callable[..., Any]],\n        ],\n    ]:\n        params = self.input_munger(module, args, kwargs)\n\n        if self.method_choice_depends_on_args:\n            # If the method choice depends on the args that get passed in,\n            # the first parameter determines which method needs to be called\n            self.json_rpc_method = self.method_choice_depends_on_args(value=params[0])\n\n            pending_or_latest_filter_methods = [\n                RPC.eth_newPendingTransactionFilter,\n                RPC.eth_newBlockFilter,\n            ]\n            if self.json_rpc_method in pending_or_latest_filter_methods:\n                # For pending or latest filter methods, use params to determine\n                # which method to call, but don't pass them through with the request\n                params = []\n\n        method = self.method_selector_fn()\n        response_formatters = (\n            self.result_formatters(method, module),\n            get_error_formatters(method),\n            self.null_result_formatters(method),\n        )\n        request = (\n            method,\n            _apply_request_formatters(params, self.request_formatters(method)),\n        )\n        return request, response_formatters\n\n\nclass DeprecatedMethod:\n    def __init__(\n        self, method: Method[Callable[..., Any]], old_name: str, new_name: str\n    ) -> None:\n        self.method = method\n        self.old_name = old_name\n        self.new_name = new_name\n\n    def __get__(\n        self, obj: Optional[\"Module\"] = None, obj_type: Optional[Type[\"Module\"]] = None\n    ) -> Any:\n        warnings.warn(\n            f\"{self.old_name} is deprecated in favor of {self.new_name}\",\n            category=DeprecationWarning,\n        )\n        return self.method.__get__(obj, obj_type)\n", "path": "web3/method.py"}, {"content": "from typing import (\n    Callable,\n)\n\nfrom eth_typing import (\n    ChecksumAddress,\n)\n\nfrom web3._utils.rpc_abi import (\n    RPC,\n)\nfrom web3.method import (\n    Method,\n    default_root_munger,\n)\nfrom web3.types import (\n    BlockNumber,\n    Wei,\n)\n\nmake_dag: Method[Callable[[BlockNumber], bool]] = Method(\n    RPC.miner_makeDag,\n    mungers=[default_root_munger],\n)\n\n\nset_extra: Method[Callable[[str], bool]] = Method(\n    RPC.miner_setExtra,\n    mungers=[default_root_munger],\n)\n\n\nset_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(\n    RPC.miner_setEtherbase,\n    mungers=[default_root_munger],\n)\n\n\nset_gas_price: Method[Callable[[Wei], bool]] = Method(\n    RPC.miner_setGasPrice,\n    mungers=[default_root_munger],\n)\n\n\nstart: Method[Callable[[int], bool]] = Method(\n    RPC.miner_start,\n    mungers=[default_root_munger],\n)\n\n\nstop: Method[Callable[[], bool]] = Method(\n    RPC.miner_stop,\n    is_property=True,\n)\n\n\nstart_auto_dag: Method[Callable[[], bool]] = Method(\n    RPC.miner_startAutoDag,\n    is_property=True,\n)\n\n\nstop_auto_dag: Method[Callable[[], bool]] = Method(\n    RPC.miner_stopAutoDag,\n    is_property=True,\n)\n", "path": "web3/_utils/miner.py"}], "after_files": [{"content": "import functools\nfrom typing import (\n    TYPE_CHECKING,\n    Any,\n    Callable,\n    Dict,\n    Generic,\n    List,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    TypeVar,\n    Union,\n)\nimport warnings\n\nfrom eth_utils.curried import (\n    to_tuple,\n)\nfrom eth_utils.toolz import (\n    pipe,\n)\n\nfrom web3._utils.method_formatters import (\n    get_error_formatters,\n    get_null_result_formatters,\n    get_request_formatters,\n    get_result_formatters,\n)\nfrom web3._utils.rpc_abi import (\n    RPC,\n)\nfrom web3.exceptions import (\n    Web3ValidationError,\n)\nfrom web3.types import (\n    RPCEndpoint,\n    TReturn,\n)\n\nif TYPE_CHECKING:\n    from web3 import Web3  # noqa: F401\n    from web3.module import Module  # noqa: F401\n\n\nMunger = Callable[..., Any]\n\n\n@to_tuple\ndef _apply_request_formatters(\n    params: Any, request_formatters: Dict[RPCEndpoint, Callable[..., TReturn]]\n) -> Tuple[Any, ...]:\n    if request_formatters:\n        formatted_params = pipe(params, request_formatters)\n        return formatted_params\n    return params\n\n\ndef _set_mungers(\n    mungers: Optional[Sequence[Munger]], is_property: bool\n) -> Sequence[Any]:\n    if is_property and mungers:\n        raise Web3ValidationError(\"Mungers cannot be used with a property.\")\n\n    return (\n        mungers\n        if mungers\n        else [default_munger] if is_property else [default_root_munger]\n    )\n\n\ndef default_munger(_module: \"Module\", *args: Any, **kwargs: Any) -> Tuple[()]:\n    if args or kwargs:\n        raise Web3ValidationError(\"Parameters cannot be passed to a property.\")\n    return ()\n\n\ndef default_root_munger(_module: \"Module\", *args: Any) -> List[Any]:\n    return [*args]\n\n\nTFunc = TypeVar(\"TFunc\", bound=Callable[..., Any])\n\n\nclass Method(Generic[TFunc]):\n    \"\"\"Method object for web3 module methods\n\n    Calls to the Method go through these steps:\n\n    1. input munging - includes normalization, parameter checking, early parameter\n    formatting. Any processing on the input parameters that need to happen before\n    json_rpc method string selection occurs.\n\n            A note about mungers: The first (root) munger should reflect the desired\n        api function arguments. In other words, if the api function wants to\n        behave as: `get_balance(account, block_identifier=None)`, the root munger\n        should accept these same arguments, with the addition of the module as\n        the first argument e.g.:\n\n        ```\n        def get_balance_root_munger(module, account, block_identifier=None):\n            if block_identifier is None:\n                block_identifier = DEFAULT_BLOCK\n            return module, [account, block_identifier]\n        ```\n\n        all mungers should return an argument list.\n\n        if no munger is provided, a default munger expecting no method arguments\n        will be used.\n\n    2. method selection - The json_rpc_method argument can be method string or a\n    function that returns a method string. If a callable is provided the processed\n    method inputs are passed to the method selection function, and the returned\n    method string is used.\n\n    3. request and response formatters are set - formatters are retrieved\n    using the json rpc method string.\n\n    4. After the parameter processing from steps 1-3 the request is made using\n    the calling function returned by the module attribute ``retrieve_caller_fn``\n    and the response formatters are applied to the output.\n    \"\"\"\n\n    def __init__(\n        self,\n        json_rpc_method: Optional[RPCEndpoint] = None,\n        mungers: Optional[Sequence[Munger]] = None,\n        request_formatters: Optional[Callable[..., TReturn]] = None,\n        result_formatters: Optional[Callable[..., TReturn]] = None,\n        null_result_formatters: Optional[Callable[..., TReturn]] = None,\n        method_choice_depends_on_args: Optional[Callable[..., RPCEndpoint]] = None,\n        is_property: bool = False,\n    ):\n        self.json_rpc_method = json_rpc_method\n        self.mungers = _set_mungers(mungers, is_property)\n        self.request_formatters = request_formatters or get_request_formatters\n        self.result_formatters = result_formatters or get_result_formatters\n        self.null_result_formatters = (\n            null_result_formatters or get_null_result_formatters\n        )\n        self.method_choice_depends_on_args = method_choice_depends_on_args\n        self.is_property = is_property\n\n    def __get__(\n        self, obj: Optional[\"Module\"] = None, obj_type: Optional[Type[\"Module\"]] = None\n    ) -> TFunc:\n        if obj is None:\n            raise TypeError(\n                \"Direct calls to methods are not supported. \"\n                \"Methods must be called from an module instance, \"\n                \"usually attached to a web3 instance.\"\n            )\n        return obj.retrieve_caller_fn(self)\n\n    @property\n    def method_selector_fn(\n        self,\n    ) -> Callable[..., Union[RPCEndpoint, Callable[..., RPCEndpoint]]]:\n        \"\"\"Gets the method selector from the config.\"\"\"\n        if callable(self.json_rpc_method):\n            return self.json_rpc_method\n        elif isinstance(self.json_rpc_method, (str,)):\n            return lambda *_: self.json_rpc_method\n        raise ValueError(\n            \"``json_rpc_method`` config invalid.  May be a string or function\"\n        )\n\n    def input_munger(self, module: \"Module\", args: Any, kwargs: Any) -> List[Any]:\n        # This function takes the input parameters and munges them.\n        # See the test_process_params test in ``tests/core/method-class/test_method.py``\n        # for an example with multiple mungers.\n        return functools.reduce(\n            lambda args, munger: munger(module, *args, **kwargs), self.mungers, args\n        )\n\n    def process_params(self, module: \"Module\", *args: Any, **kwargs: Any) -> Tuple[\n        Tuple[Union[RPCEndpoint, Callable[..., RPCEndpoint]], Tuple[Any, ...]],\n        Tuple[\n            Union[TReturn, Dict[str, Callable[..., Any]]],\n            Callable[..., Any],\n            Union[TReturn, Callable[..., Any]],\n        ],\n    ]:\n        params = self.input_munger(module, args, kwargs)\n\n        if self.method_choice_depends_on_args:\n            # If the method choice depends on the args that get passed in,\n            # the first parameter determines which method needs to be called\n            self.json_rpc_method = self.method_choice_depends_on_args(value=params[0])\n\n            pending_or_latest_filter_methods = [\n                RPC.eth_newPendingTransactionFilter,\n                RPC.eth_newBlockFilter,\n            ]\n            if self.json_rpc_method in pending_or_latest_filter_methods:\n                # For pending or latest filter methods, use params to determine\n                # which method to call, but don't pass them through with the request\n                params = []\n\n        method = self.method_selector_fn()\n        response_formatters = (\n            self.result_formatters(method, module),\n            get_error_formatters(method),\n            self.null_result_formatters(method),\n        )\n        request = (\n            method,\n            _apply_request_formatters(params, self.request_formatters(method)),\n        )\n        return request, response_formatters\n\n\nclass DeprecatedMethod:\n    def __init__(\n        self,\n        method: Method[Callable[..., Any]],\n        old_name: str,\n        new_name: Optional[str] = None,\n        msg: Optional[str] = None,\n    ) -> None:\n        self.method = method\n        self.old_name = old_name\n        self.new_name = new_name\n        self.msg = msg\n\n    def __get__(\n        self, obj: Optional[\"Module\"] = None, obj_type: Optional[Type[\"Module\"]] = None\n    ) -> Any:\n        message = f\"{self.old_name} is deprecated in favor of {self.new_name}\"\n        if self.msg is not None:\n            message = self.msg\n\n        warnings.warn(\n            message,\n            category=DeprecationWarning,\n        )\n        return self.method.__get__(obj, obj_type)\n", "path": "web3/method.py"}, {"content": "from typing import (\n    Callable,\n)\n\nfrom eth_typing import (\n    ChecksumAddress,\n)\n\nfrom web3._utils.rpc_abi import (\n    RPC,\n)\nfrom web3.method import (\n    DeprecatedMethod,\n    Method,\n    default_root_munger,\n)\nfrom web3.types import (\n    BlockNumber,\n    Wei,\n)\n\n#\n# The Geth client deprecated the miner namespace.\n#\n\n_make_dag: Method[Callable[[BlockNumber], bool]] = Method(\n    RPC.miner_makeDag,\n    mungers=[default_root_munger],\n)\n\nmake_dag = DeprecatedMethod(\n    _make_dag, \"make_dag\", msg=\"All mining methods have been deprecated\"\n)\n\n_set_extra: Method[Callable[[str], bool]] = Method(\n    RPC.miner_setExtra,\n    mungers=[default_root_munger],\n)\n\nset_extra = DeprecatedMethod(\n    _set_extra, \"set_extra\", msg=\"All mining methods have been deprecated\"\n)\n\n_set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(\n    RPC.miner_setEtherbase,\n    mungers=[default_root_munger],\n)\n\nset_etherbase = DeprecatedMethod(\n    _set_etherbase, \"set_etherbase\", msg=\"All mining methods have been deprecated\"\n)\n\n_set_gas_price: Method[Callable[[Wei], bool]] = Method(\n    RPC.miner_setGasPrice,\n    mungers=[default_root_munger],\n)\n\nset_gas_price = DeprecatedMethod(\n    _set_gas_price, \"set_gas_price\", msg=\"All mining methods have been deprecated\"\n)\n\n_start: Method[Callable[[int], bool]] = Method(\n    RPC.miner_start,\n    mungers=[default_root_munger],\n)\n\nstart = DeprecatedMethod(_start, \"start\", msg=\"All mining methods have been deprecated\")\n\n_stop: Method[Callable[[], bool]] = Method(\n    RPC.miner_stop,\n    is_property=True,\n)\n\nstop = DeprecatedMethod(_stop, \"stop\", msg=\"All mining methods have been deprecated\")\n\n_start_auto_dag: Method[Callable[[], bool]] = Method(\n    RPC.miner_startAutoDag,\n    is_property=True,\n)\n\nstart_auto_dag = DeprecatedMethod(\n    _start_auto_dag, \"start_auto_dag\", msg=\"All mining methods have been deprecated\"\n)\n\n_stop_auto_dag: Method[Callable[[], bool]] = Method(\n    RPC.miner_stopAutoDag,\n    is_property=True,\n)\n\nstop_auto_dag = DeprecatedMethod(\n    _stop_auto_dag, \"stop_auto_dag\", msg=\"All mining methods have been deprecated\"\n)\n", "path": "web3/_utils/miner.py"}]}