Fix hacking.py to handle parenthesise in from import as
Fix bug 1133070 Support 'from os import (path as p)' Change-Id: Ie2e5b3150efb6f47b16978f3de64fca37e1717a6
This commit is contained in:
@@ -176,9 +176,12 @@ def nova_import_rules(logical_line):
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
Okay: from os import path
|
Okay: from os import path
|
||||||
|
Okay: from os import path as p
|
||||||
|
Okay: from os import (path as p)
|
||||||
Okay: import os.path
|
Okay: import os.path
|
||||||
Okay: from nova.compute import rpcapi
|
Okay: from nova.compute import rpcapi
|
||||||
N302: from os.path import dirname as dirname2
|
N302: from os.path import dirname as dirname2
|
||||||
|
N302: from os.path import (dirname as dirname2)
|
||||||
N303: from os.path import *
|
N303: from os.path import *
|
||||||
N304: from .compute import rpcapi
|
N304: from .compute import rpcapi
|
||||||
"""
|
"""
|
||||||
@@ -186,6 +189,7 @@ def nova_import_rules(logical_line):
|
|||||||
# pass the doctest, since the relativity depends on the file's locality
|
# pass the doctest, since the relativity depends on the file's locality
|
||||||
|
|
||||||
def is_module_for_sure(mod, search_path=sys.path):
|
def is_module_for_sure(mod, search_path=sys.path):
|
||||||
|
mod = mod.replace('(', '') # Ignore parentheses
|
||||||
try:
|
try:
|
||||||
mod_name = mod
|
mod_name = mod
|
||||||
while '.' in mod_name:
|
while '.' in mod_name:
|
||||||
|
|||||||
Reference in New Issue
Block a user