We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Rename middleware_stack to middleware_onion
### How can it be fixed?

see #1020  


--- 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/__init__.py`
Content:
```
1 import pkg_resources
2 import sys
3 
4 if sys.version_info < (3, 5):
5     raise EnvironmentError("Python 3.5 or above is required")
6 
7 from eth_account import Account  # noqa: E402
8 from web3.main import Web3  # noqa: E402
9 from web3.providers.rpc import (  # noqa: E402
10     HTTPProvider,
11 )
12 from web3.providers.eth_tester import (  # noqa: E402
13     EthereumTesterProvider,
14 )
15 from web3.providers.tester import (  # noqa: E402
16     TestRPCProvider,
17 )
18 from web3.providers.ipc import (  # noqa: E402
19     IPCProvider,
20 )
21 from web3.providers.websocket import (  # noqa: E402
22     WebsocketProvider,
23 )
24 
25 __version__ = pkg_resources.get_distribution("web3").version
26 
27 __all__ = [
28     "__version__",
29     "Web3",
30     "HTTPProvider",
31     "IPCProvider",
32     "WebsocketProvider",
33     "TestRPCProvider",
34     "EthereumTesterProvider",
35     "Account",
36 ]
37
```

Path: `web3/main.py`
Content:
```
1 from eth_utils import (
2     apply_to_return_value,
3     add_0x_prefix,
4     from_wei,
5     is_address,
6     is_checksum_address,
7     keccak,
8     remove_0x_prefix,
9     to_checksum_address,
10     to_wei,
11 )
12 
13 from ens import ENS
14 
15 from web3.admin import Admin
16 from web3.eth import Eth
17 from web3.iban import Iban
18 from web3.miner import Miner
19 from web3.net import Net
20 from web3.parity import Parity
21 from web3.personal import Personal
22 from web3.testing import Testing
23 from web3.txpool import TxPool
24 from web3.version import Version
25 
26 from web3.providers.eth_tester import (
27     EthereumTesterProvider,
28 )
29 from web3.providers.ipc import (
30     IPCProvider,
31 )
32 from web3.providers.rpc import (
33     HTTPProvider,
34 )
35 from web3.providers.tester import (
36     TestRPCProvider,
37 )
38 from web3.providers.websocket import (
39     WebsocketProvider
40 )
41 
42 from web3.manager import (
43     RequestManager,
44 )
45 
46 from web3.utils.abi import (
47     map_abi_data,
48 )
49 from hexbytes import (
50     HexBytes,
51 )
52 from web3.utils.decorators import (
53     combomethod,
54 )
55 from web3.utils.empty import empty
56 from web3.utils.encoding import (
57     hex_encode_abi_type,
58     to_bytes,
59     to_int,
60     to_hex,
61     to_text,
62 )
63 from web3.utils.normalizers import (
64     abi_ens_resolver,
65 )
66 
67 
68 def get_default_modules():
69     return {
70         "eth": Eth,
71         "net": Net,
72         "personal": Personal,
73         "version": Version,
74         "txpool": TxPool,
75         "miner": Miner,
76         "admin": Admin,
77         "parity": Parity,
78         "testing": Testing,
79     }
80 
81 
82 class Web3:
83     # Providers
84     HTTPProvider = HTTPProvider
85     IPCProvider = IPCProvider
86     TestRPCProvider = TestRPCProvider
87     EthereumTesterProvider = EthereumTesterProvider
88     WebsocketProvider = WebsocketProvider
89 
90     # Managers
91     RequestManager = RequestManager
92 
93     # Iban
94     Iban = Iban
95 
96     # Encoding and Decoding
97     toBytes = staticmethod(to_bytes)
98     toInt = staticmethod(to_int)
99     toHex = staticmethod(to_hex)
100     toText = staticmethod(to_text)
101 
102     # Currency Utility
103     toWei = staticmethod(to_wei)
104     fromWei = staticmethod(from_wei)
105 
106     # Address Utility
107     isAddress = staticmethod(is_address)
108     isChecksumAddress = staticmethod(is_checksum_address)
109     toChecksumAddress = staticmethod(to_checksum_address)
110 
111     def __init__(self, providers=empty, middlewares=None, modules=None, ens=empty):
112         self.manager = RequestManager(self, providers, middlewares)
113 
114         if modules is None:
115             modules = get_default_modules()
116 
117         for module_name, module_class in modules.items():
118             module_class.attach(self, module_name)
119 
120         self.ens = ens
121 
122     @property
123     def middleware_stack(self):
124         return self.manager.middleware_stack
125 
126     @property
127     def providers(self):
128         return self.manager.providers
129 
130     @providers.setter
131     def providers(self, providers):
132         self.manager.providers = providers
133 
134     @staticmethod
135     @apply_to_return_value(HexBytes)
136     def sha3(primitive=None, text=None, hexstr=None):
137         if isinstance(primitive, (bytes, int, type(None))):
138             input_bytes = to_bytes(primitive, hexstr=hexstr, text=text)
139             return keccak(input_bytes)
140 
141         raise TypeError(
142             "You called sha3 with first arg %r and keywords %r. You must call it with one of "
143             "these approaches: sha3(text='txt'), sha3(hexstr='0x747874'), "
144             "sha3(b'\\x74\\x78\\x74'), or sha3(0x747874)." % (
145                 primitive,
146                 {'text': text, 'hexstr': hexstr}
147             )
148         )
149 
150     @combomethod
151     def soliditySha3(cls, abi_types, values):
152         """
153         Executes sha3 (keccak256) exactly as Solidity does.
154         Takes list of abi_types as inputs -- `[uint24, int8[], bool]`
155         and list of corresponding values  -- `[20, [-1, 5, 0], True]`
156         """
157         if len(abi_types) != len(values):
158             raise ValueError(
159                 "Length mismatch between provided abi types and values.  Got "
160                 "{0} types and {1} values.".format(len(abi_types), len(values))
161             )
162 
163         if isinstance(cls, type):
164             w3 = None
165         else:
166             w3 = cls
167         normalized_values = map_abi_data([abi_ens_resolver(w3)], abi_types, values)
168 
169         hex_string = add_0x_prefix(''.join(
170             remove_0x_prefix(hex_encode_abi_type(abi_type, value))
171             for abi_type, value
172             in zip(abi_types, normalized_values)
173         ))
174         return cls.sha3(hexstr=hex_string)
175 
176     def isConnected(self):
177         for provider in self.providers:
178             if provider.isConnected():
179                 return True
180         else:
181             return False
182 
183     @property
184     def ens(self):
185         if self._ens is empty:
186             return ENS.fromWeb3(self)
187         else:
188             return self._ens
189 
190     @ens.setter
191     def ens(self, new_ens):
192         self._ens = new_ens
193
```
--- 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/__init__.py b/web3/__init__.py
--- a/web3/__init__.py
+++ b/web3/__init__.py
@@ -1,8 +1,17 @@
 import pkg_resources
 import sys
+import warnings
+
+if (3, 5) <= sys.version_info < (3, 6):
+    warnings.warn(
+        "Support for Python 3.5 will be removed in web3.py v5",
+        category=DeprecationWarning,
+        stacklevel=2)
 
 if sys.version_info < (3, 5):
-    raise EnvironmentError("Python 3.5 or above is required")
+    raise EnvironmentError(
+        "Python 3.5 or above is required. "
+        "Note that support for Python 3.5 will be remove in web3.py v5")
 
 from eth_account import Account  # noqa: E402
 from web3.main import Web3  # noqa: E402
diff --git a/web3/main.py b/web3/main.py
--- a/web3/main.py
+++ b/web3/main.py
@@ -4,7 +4,7 @@
     from_wei,
     is_address,
     is_checksum_address,
-    keccak,
+    keccak as eth_utils_keccak,
     remove_0x_prefix,
     to_checksum_address,
     to_wei,
@@ -51,6 +51,7 @@
 )
 from web3.utils.decorators import (
     combomethod,
+    deprecated_for,
 )
 from web3.utils.empty import empty
 from web3.utils.encoding import (
@@ -132,16 +133,22 @@
         self.manager.providers = providers
 
     @staticmethod
+    @deprecated_for("This method has been renamed to keccak")
     @apply_to_return_value(HexBytes)
     def sha3(primitive=None, text=None, hexstr=None):
+        return Web3.keccak(primitive, text, hexstr)
+
+    @staticmethod
+    @apply_to_return_value(HexBytes)
+    def keccak(primitive=None, text=None, hexstr=None):
         if isinstance(primitive, (bytes, int, type(None))):
             input_bytes = to_bytes(primitive, hexstr=hexstr, text=text)
-            return keccak(input_bytes)
+            return eth_utils_keccak(input_bytes)
 
         raise TypeError(
-            "You called sha3 with first arg %r and keywords %r. You must call it with one of "
-            "these approaches: sha3(text='txt'), sha3(hexstr='0x747874'), "
-            "sha3(b'\\x74\\x78\\x74'), or sha3(0x747874)." % (
+            "You called keccak with first arg %r and keywords %r. You must call it with one of "
+            "these approaches: keccak(text='txt'), keccak(hexstr='0x747874'), "
+            "keccak(b'\\x74\\x78\\x74'), or keccak(0x747874)." % (
                 primitive,
                 {'text': text, 'hexstr': hexstr}
             )

{"golden_diff": "diff --git a/web3/__init__.py b/web3/__init__.py\n--- a/web3/__init__.py\n+++ b/web3/__init__.py\n@@ -1,8 +1,17 @@\n import pkg_resources\n import sys\n+import warnings\n+\n+if (3, 5) <= sys.version_info < (3, 6):\n+    warnings.warn(\n+        \"Support for Python 3.5 will be removed in web3.py v5\",\n+        category=DeprecationWarning,\n+        stacklevel=2)\n \n if sys.version_info < (3, 5):\n-    raise EnvironmentError(\"Python 3.5 or above is required\")\n+    raise EnvironmentError(\n+        \"Python 3.5 or above is required. \"\n+        \"Note that support for Python 3.5 will be remove in web3.py v5\")\n \n from eth_account import Account  # noqa: E402\n from web3.main import Web3  # noqa: E402\ndiff --git a/web3/main.py b/web3/main.py\n--- a/web3/main.py\n+++ b/web3/main.py\n@@ -4,7 +4,7 @@\n     from_wei,\n     is_address,\n     is_checksum_address,\n-    keccak,\n+    keccak as eth_utils_keccak,\n     remove_0x_prefix,\n     to_checksum_address,\n     to_wei,\n@@ -51,6 +51,7 @@\n )\n from web3.utils.decorators import (\n     combomethod,\n+    deprecated_for,\n )\n from web3.utils.empty import empty\n from web3.utils.encoding import (\n@@ -132,16 +133,22 @@\n         self.manager.providers = providers\n \n     @staticmethod\n+    @deprecated_for(\"This method has been renamed to keccak\")\n     @apply_to_return_value(HexBytes)\n     def sha3(primitive=None, text=None, hexstr=None):\n+        return Web3.keccak(primitive, text, hexstr)\n+\n+    @staticmethod\n+    @apply_to_return_value(HexBytes)\n+    def keccak(primitive=None, text=None, hexstr=None):\n         if isinstance(primitive, (bytes, int, type(None))):\n             input_bytes = to_bytes(primitive, hexstr=hexstr, text=text)\n-            return keccak(input_bytes)\n+            return eth_utils_keccak(input_bytes)\n \n         raise TypeError(\n-            \"You called sha3 with first arg %r and keywords %r. You must call it with one of \"\n-            \"these approaches: sha3(text='txt'), sha3(hexstr='0x747874'), \"\n-            \"sha3(b'\\\\x74\\\\x78\\\\x74'), or sha3(0x747874).\" % (\n+            \"You called keccak with first arg %r and keywords %r. You must call it with one of \"\n+            \"these approaches: keccak(text='txt'), keccak(hexstr='0x747874'), \"\n+            \"keccak(b'\\\\x74\\\\x78\\\\x74'), or keccak(0x747874).\" % (\n                 primitive,\n                 {'text': text, 'hexstr': hexstr}\n             )\n", "issue": "Rename middleware_stack to middleware_onion\n### How can it be fixed?\r\n\r\nsee #1020  \r\n\n", "before_files": [{"content": "import pkg_resources\nimport sys\n\nif sys.version_info < (3, 5):\n    raise EnvironmentError(\"Python 3.5 or above is required\")\n\nfrom eth_account import Account  # noqa: E402\nfrom web3.main import Web3  # noqa: E402\nfrom web3.providers.rpc import (  # noqa: E402\n    HTTPProvider,\n)\nfrom web3.providers.eth_tester import (  # noqa: E402\n    EthereumTesterProvider,\n)\nfrom web3.providers.tester import (  # noqa: E402\n    TestRPCProvider,\n)\nfrom web3.providers.ipc import (  # noqa: E402\n    IPCProvider,\n)\nfrom web3.providers.websocket import (  # noqa: E402\n    WebsocketProvider,\n)\n\n__version__ = pkg_resources.get_distribution(\"web3\").version\n\n__all__ = [\n    \"__version__\",\n    \"Web3\",\n    \"HTTPProvider\",\n    \"IPCProvider\",\n    \"WebsocketProvider\",\n    \"TestRPCProvider\",\n    \"EthereumTesterProvider\",\n    \"Account\",\n]\n", "path": "web3/__init__.py"}, {"content": "from eth_utils import (\n    apply_to_return_value,\n    add_0x_prefix,\n    from_wei,\n    is_address,\n    is_checksum_address,\n    keccak,\n    remove_0x_prefix,\n    to_checksum_address,\n    to_wei,\n)\n\nfrom ens import ENS\n\nfrom web3.admin import Admin\nfrom web3.eth import Eth\nfrom web3.iban import Iban\nfrom web3.miner import Miner\nfrom web3.net import Net\nfrom web3.parity import Parity\nfrom web3.personal import Personal\nfrom web3.testing import Testing\nfrom web3.txpool import TxPool\nfrom web3.version import Version\n\nfrom web3.providers.eth_tester import (\n    EthereumTesterProvider,\n)\nfrom web3.providers.ipc import (\n    IPCProvider,\n)\nfrom web3.providers.rpc import (\n    HTTPProvider,\n)\nfrom web3.providers.tester import (\n    TestRPCProvider,\n)\nfrom web3.providers.websocket import (\n    WebsocketProvider\n)\n\nfrom web3.manager import (\n    RequestManager,\n)\n\nfrom web3.utils.abi import (\n    map_abi_data,\n)\nfrom hexbytes import (\n    HexBytes,\n)\nfrom web3.utils.decorators import (\n    combomethod,\n)\nfrom web3.utils.empty import empty\nfrom web3.utils.encoding import (\n    hex_encode_abi_type,\n    to_bytes,\n    to_int,\n    to_hex,\n    to_text,\n)\nfrom web3.utils.normalizers import (\n    abi_ens_resolver,\n)\n\n\ndef get_default_modules():\n    return {\n        \"eth\": Eth,\n        \"net\": Net,\n        \"personal\": Personal,\n        \"version\": Version,\n        \"txpool\": TxPool,\n        \"miner\": Miner,\n        \"admin\": Admin,\n        \"parity\": Parity,\n        \"testing\": Testing,\n    }\n\n\nclass Web3:\n    # Providers\n    HTTPProvider = HTTPProvider\n    IPCProvider = IPCProvider\n    TestRPCProvider = TestRPCProvider\n    EthereumTesterProvider = EthereumTesterProvider\n    WebsocketProvider = WebsocketProvider\n\n    # Managers\n    RequestManager = RequestManager\n\n    # Iban\n    Iban = Iban\n\n    # Encoding and Decoding\n    toBytes = staticmethod(to_bytes)\n    toInt = staticmethod(to_int)\n    toHex = staticmethod(to_hex)\n    toText = staticmethod(to_text)\n\n    # Currency Utility\n    toWei = staticmethod(to_wei)\n    fromWei = staticmethod(from_wei)\n\n    # Address Utility\n    isAddress = staticmethod(is_address)\n    isChecksumAddress = staticmethod(is_checksum_address)\n    toChecksumAddress = staticmethod(to_checksum_address)\n\n    def __init__(self, providers=empty, middlewares=None, modules=None, ens=empty):\n        self.manager = RequestManager(self, providers, middlewares)\n\n        if modules is None:\n            modules = get_default_modules()\n\n        for module_name, module_class in modules.items():\n            module_class.attach(self, module_name)\n\n        self.ens = ens\n\n    @property\n    def middleware_stack(self):\n        return self.manager.middleware_stack\n\n    @property\n    def providers(self):\n        return self.manager.providers\n\n    @providers.setter\n    def providers(self, providers):\n        self.manager.providers = providers\n\n    @staticmethod\n    @apply_to_return_value(HexBytes)\n    def sha3(primitive=None, text=None, hexstr=None):\n        if isinstance(primitive, (bytes, int, type(None))):\n            input_bytes = to_bytes(primitive, hexstr=hexstr, text=text)\n            return keccak(input_bytes)\n\n        raise TypeError(\n            \"You called sha3 with first arg %r and keywords %r. You must call it with one of \"\n            \"these approaches: sha3(text='txt'), sha3(hexstr='0x747874'), \"\n            \"sha3(b'\\\\x74\\\\x78\\\\x74'), or sha3(0x747874).\" % (\n                primitive,\n                {'text': text, 'hexstr': hexstr}\n            )\n        )\n\n    @combomethod\n    def soliditySha3(cls, abi_types, values):\n        \"\"\"\n        Executes sha3 (keccak256) exactly as Solidity does.\n        Takes list of abi_types as inputs -- `[uint24, int8[], bool]`\n        and list of corresponding values  -- `[20, [-1, 5, 0], True]`\n        \"\"\"\n        if len(abi_types) != len(values):\n            raise ValueError(\n                \"Length mismatch between provided abi types and values.  Got \"\n                \"{0} types and {1} values.\".format(len(abi_types), len(values))\n            )\n\n        if isinstance(cls, type):\n            w3 = None\n        else:\n            w3 = cls\n        normalized_values = map_abi_data([abi_ens_resolver(w3)], abi_types, values)\n\n        hex_string = add_0x_prefix(''.join(\n            remove_0x_prefix(hex_encode_abi_type(abi_type, value))\n            for abi_type, value\n            in zip(abi_types, normalized_values)\n        ))\n        return cls.sha3(hexstr=hex_string)\n\n    def isConnected(self):\n        for provider in self.providers:\n            if provider.isConnected():\n                return True\n        else:\n            return False\n\n    @property\n    def ens(self):\n        if self._ens is empty:\n            return ENS.fromWeb3(self)\n        else:\n            return self._ens\n\n    @ens.setter\n    def ens(self, new_ens):\n        self._ens = new_ens\n", "path": "web3/main.py"}], "after_files": [{"content": "import pkg_resources\nimport sys\nimport warnings\n\nif (3, 5) <= sys.version_info < (3, 6):\n    warnings.warn(\n        \"Support for Python 3.5 will be removed in web3.py v5\",\n        category=DeprecationWarning,\n        stacklevel=2)\n\nif sys.version_info < (3, 5):\n    raise EnvironmentError(\n        \"Python 3.5 or above is required. \"\n        \"Note that support for Python 3.5 will be remove in web3.py v5\")\n\nfrom eth_account import Account  # noqa: E402\nfrom web3.main import Web3  # noqa: E402\nfrom web3.providers.rpc import (  # noqa: E402\n    HTTPProvider,\n)\nfrom web3.providers.eth_tester import (  # noqa: E402\n    EthereumTesterProvider,\n)\nfrom web3.providers.tester import (  # noqa: E402\n    TestRPCProvider,\n)\nfrom web3.providers.ipc import (  # noqa: E402\n    IPCProvider,\n)\nfrom web3.providers.websocket import (  # noqa: E402\n    WebsocketProvider,\n)\n\n__version__ = pkg_resources.get_distribution(\"web3\").version\n\n__all__ = [\n    \"__version__\",\n    \"Web3\",\n    \"HTTPProvider\",\n    \"IPCProvider\",\n    \"WebsocketProvider\",\n    \"TestRPCProvider\",\n    \"EthereumTesterProvider\",\n    \"Account\",\n]\n", "path": "web3/__init__.py"}, {"content": "from eth_utils import (\n    apply_to_return_value,\n    add_0x_prefix,\n    from_wei,\n    is_address,\n    is_checksum_address,\n    keccak as eth_utils_keccak,\n    remove_0x_prefix,\n    to_checksum_address,\n    to_wei,\n)\n\nfrom ens import ENS\n\nfrom web3.admin import Admin\nfrom web3.eth import Eth\nfrom web3.iban import Iban\nfrom web3.miner import Miner\nfrom web3.net import Net\nfrom web3.parity import Parity\nfrom web3.personal import Personal\nfrom web3.testing import Testing\nfrom web3.txpool import TxPool\nfrom web3.version import Version\n\nfrom web3.providers.eth_tester import (\n    EthereumTesterProvider,\n)\nfrom web3.providers.ipc import (\n    IPCProvider,\n)\nfrom web3.providers.rpc import (\n    HTTPProvider,\n)\nfrom web3.providers.tester import (\n    TestRPCProvider,\n)\nfrom web3.providers.websocket import (\n    WebsocketProvider\n)\n\nfrom web3.manager import (\n    RequestManager,\n)\n\nfrom web3.utils.abi import (\n    map_abi_data,\n)\nfrom hexbytes import (\n    HexBytes,\n)\nfrom web3.utils.decorators import (\n    combomethod,\n    deprecated_for,\n)\nfrom web3.utils.empty import empty\nfrom web3.utils.encoding import (\n    hex_encode_abi_type,\n    to_bytes,\n    to_int,\n    to_hex,\n    to_text,\n)\nfrom web3.utils.normalizers import (\n    abi_ens_resolver,\n)\n\n\ndef get_default_modules():\n    return {\n        \"eth\": Eth,\n        \"net\": Net,\n        \"personal\": Personal,\n        \"version\": Version,\n        \"txpool\": TxPool,\n        \"miner\": Miner,\n        \"admin\": Admin,\n        \"parity\": Parity,\n        \"testing\": Testing,\n    }\n\n\nclass Web3:\n    # Providers\n    HTTPProvider = HTTPProvider\n    IPCProvider = IPCProvider\n    TestRPCProvider = TestRPCProvider\n    EthereumTesterProvider = EthereumTesterProvider\n    WebsocketProvider = WebsocketProvider\n\n    # Managers\n    RequestManager = RequestManager\n\n    # Iban\n    Iban = Iban\n\n    # Encoding and Decoding\n    toBytes = staticmethod(to_bytes)\n    toInt = staticmethod(to_int)\n    toHex = staticmethod(to_hex)\n    toText = staticmethod(to_text)\n\n    # Currency Utility\n    toWei = staticmethod(to_wei)\n    fromWei = staticmethod(from_wei)\n\n    # Address Utility\n    isAddress = staticmethod(is_address)\n    isChecksumAddress = staticmethod(is_checksum_address)\n    toChecksumAddress = staticmethod(to_checksum_address)\n\n    def __init__(self, providers=empty, middlewares=None, modules=None, ens=empty):\n        self.manager = RequestManager(self, providers, middlewares)\n\n        if modules is None:\n            modules = get_default_modules()\n\n        for module_name, module_class in modules.items():\n            module_class.attach(self, module_name)\n\n        self.ens = ens\n\n    @property\n    def middleware_stack(self):\n        return self.manager.middleware_stack\n\n    @property\n    def providers(self):\n        return self.manager.providers\n\n    @providers.setter\n    def providers(self, providers):\n        self.manager.providers = providers\n\n    @staticmethod\n    @deprecated_for(\"This method has been renamed to keccak\")\n    @apply_to_return_value(HexBytes)\n    def sha3(primitive=None, text=None, hexstr=None):\n        return Web3.keccak(primitive, text, hexstr)\n\n    @staticmethod\n    @apply_to_return_value(HexBytes)\n    def keccak(primitive=None, text=None, hexstr=None):\n        if isinstance(primitive, (bytes, int, type(None))):\n            input_bytes = to_bytes(primitive, hexstr=hexstr, text=text)\n            return eth_utils_keccak(input_bytes)\n\n        raise TypeError(\n            \"You called keccak with first arg %r and keywords %r. You must call it with one of \"\n            \"these approaches: keccak(text='txt'), keccak(hexstr='0x747874'), \"\n            \"keccak(b'\\\\x74\\\\x78\\\\x74'), or keccak(0x747874).\" % (\n                primitive,\n                {'text': text, 'hexstr': hexstr}\n            )\n        )\n\n    @combomethod\n    def soliditySha3(cls, abi_types, values):\n        \"\"\"\n        Executes sha3 (keccak256) exactly as Solidity does.\n        Takes list of abi_types as inputs -- `[uint24, int8[], bool]`\n        and list of corresponding values  -- `[20, [-1, 5, 0], True]`\n        \"\"\"\n        if len(abi_types) != len(values):\n            raise ValueError(\n                \"Length mismatch between provided abi types and values.  Got \"\n                \"{0} types and {1} values.\".format(len(abi_types), len(values))\n            )\n\n        if isinstance(cls, type):\n            w3 = None\n        else:\n            w3 = cls\n        normalized_values = map_abi_data([abi_ens_resolver(w3)], abi_types, values)\n\n        hex_string = add_0x_prefix(''.join(\n            remove_0x_prefix(hex_encode_abi_type(abi_type, value))\n            for abi_type, value\n            in zip(abi_types, normalized_values)\n        ))\n        return cls.sha3(hexstr=hex_string)\n\n    def isConnected(self):\n        for provider in self.providers:\n            if provider.isConnected():\n                return True\n        else:\n            return False\n\n    @property\n    def ens(self):\n        if self._ens is empty:\n            return ENS.fromWeb3(self)\n        else:\n            return self._ens\n\n    @ens.setter\n    def ens(self, new_ens):\n        self._ens = new_ens\n", "path": "web3/main.py"}]}