File tree Expand file tree Collapse file tree 7 files changed +54
-29
lines changed Expand file tree Collapse file tree 7 files changed +54
-29
lines changed Original file line number Diff line number Diff line change
1
+ from contextlib import contextmanager
2
+ import warnings
3
+
4
+
5
+ # TODO: drop once https://github.com/cython/cython/issues/1720 is resolved
6
+ @contextmanager
7
+ def catch_and_ignore_import_warning ():
8
+ with warnings .catch_warnings ():
9
+ warnings .simplefilter ('ignore' , category = ImportWarning )
10
+ yield
Original file line number Diff line number Diff line change 28
28
Hash32 ,
29
29
)
30
30
31
- from eth_utils import (
32
- to_set ,
33
- ValidationError ,
34
- )
35
- from eth_utils .toolz import (
36
- assoc ,
37
- compose ,
38
- groupby ,
39
- iterate ,
40
- take ,
41
- )
42
-
43
31
from eth .db .backends .base import BaseAtomicDB
44
32
from eth .db .chain import (
45
33
BaseChainDB ,
103
91
AccountState ,
104
92
)
105
93
94
+ from eth ._warnings import catch_and_ignore_import_warning
95
+ with catch_and_ignore_import_warning ():
96
+ from eth_utils import (
97
+ to_set ,
98
+ ValidationError ,
99
+ )
100
+ from eth_utils .toolz import (
101
+ assoc ,
102
+ compose ,
103
+ groupby ,
104
+ iterate ,
105
+ take ,
106
+ )
107
+
106
108
if TYPE_CHECKING :
107
109
from eth .vm .base import BaseVM # noqa: F401
108
110
Original file line number Diff line number Diff line change 2
2
Address ,
3
3
Hash32
4
4
)
5
- from eth_utils import denoms
5
+
6
+ from eth ._warnings import catch_and_ignore_import_warning
7
+ with catch_and_ignore_import_warning ():
8
+ from eth_utils import denoms
6
9
7
10
8
11
ANY = 'any'
Original file line number Diff line number Diff line change 17
17
BaseDB ,
18
18
)
19
19
20
+ from eth ._warnings import catch_and_ignore_import_warning
21
+
20
22
if TYPE_CHECKING :
21
- import plyvel # noqa: F401
23
+ with catch_and_ignore_import_warning ():
24
+ import plyvel # noqa: F401
22
25
23
26
24
27
class LevelDB (BaseAtomicDB ):
@@ -29,7 +32,8 @@ def __init__(self, db_path: Path = None) -> None:
29
32
if not db_path :
30
33
raise TypeError ("Please specifiy a valid path for your database." )
31
34
try :
32
- import plyvel # noqa: F811
35
+ with catch_and_ignore_import_warning ():
36
+ import plyvel # noqa: F811
33
37
except ImportError :
34
38
raise ImportError (
35
39
"LevelDB requires the plyvel library which is not available for import."
Original file line number Diff line number Diff line change 13
13
TYPE_CHECKING ,
14
14
)
15
15
16
- import rlp
17
-
18
- from trie import (
19
- HexaryTrie ,
20
- )
21
-
22
16
from eth_typing import (
23
17
BlockNumber ,
24
18
Hash32
25
19
)
26
20
27
- from eth_utils import (
28
- to_list ,
29
- to_tuple ,
30
- ValidationError ,
31
- )
32
-
33
21
from eth_hash .auto import keccak
34
22
35
23
from eth .constants import (
57
45
from eth .validation import (
58
46
validate_word ,
59
47
)
48
+ from eth ._warnings import catch_and_ignore_import_warning
49
+ with catch_and_ignore_import_warning ():
50
+ import rlp
51
+ from trie import (
52
+ HexaryTrie ,
53
+ )
54
+ from eth_utils import (
55
+ to_list ,
56
+ to_tuple ,
57
+ ValidationError ,
58
+ )
60
59
61
60
if TYPE_CHECKING :
62
61
from eth .rlp .blocks import ( # noqa: F401
Original file line number Diff line number Diff line change 18
18
)
19
19
import netifaces
20
20
from p2p .service import BaseService
21
- import upnpclient
21
+
22
+ from eth ._warnings import catch_and_ignore_import_warning
23
+ with catch_and_ignore_import_warning ():
24
+ import upnpclient
22
25
23
26
24
27
# UPnP discovery can take a long time, so use a loooong timeout here.
Original file line number Diff line number Diff line change @@ -21,7 +21,11 @@ def is_uvloop_supported() -> bool:
21
21
if is_uvloop_supported ():
22
22
# Set `uvloop` as the default event loop
23
23
import asyncio # noqa: E402
24
- import uvloop # noqa: E402
24
+
25
+ from eth ._warnings import catch_and_ignore_import_warning
26
+ with catch_and_ignore_import_warning ():
27
+ import uvloop # noqa: E402
28
+
25
29
asyncio .set_event_loop_policy (uvloop .EventLoopPolicy ())
26
30
27
31
from .main import ( # noqa: F401
You can’t perform that action at this time.
0 commit comments