File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -24,9 +24,32 @@ The ``import`` statement should be refactored to be more specific about what fun
24
24
25
25
from math import ceil
26
26
27
+ Import the whole module
28
+ .......................
29
+
30
+ There are some cases where making the ``import `` statement spesific is not a good solution:
31
+
32
+ - It may be unpractical or cumbersome to create or maintain the list of objects to be imported from a module
33
+ - A direct import would bind to the same name as that of another object (e.g. from asyncio import TimeoutError)
34
+ - The module that the object is imported from would provide valuable contextual information if it is right next to the object when it's used.
35
+
36
+ In these cases, use one of these idioms:
37
+
38
+ .. code :: python
39
+
40
+ import math
41
+ x = math.ceil(y)
42
+
43
+ # or
44
+
45
+ import multiprocessing as mp
46
+ pool = mp.pool(8 )
47
+
48
+
27
49
References
28
50
----------
29
51
30
52
- PyFlakes - F403
31
53
- `Stack Overflow - Importing Modules <http://stackoverflow.com/questions/15145159/importing-modules-how-much-is-too-much >`_
54
+ - `Stack Overflow - 'import module' or 'from module import' <http://stackoverflow.com/questions/710551/import-module-or-from-module-import >`_
32
55
You can’t perform that action at this time.
0 commit comments