summaryrefslogtreecommitdiff
path: root/astroid/modutils.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-12-14 03:10:31 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-12-14 03:10:31 +0200
commitd65e7cd75d368a075ff271c8320e94ebf2f2d9b1 (patch)
tree0c5dd609a5c90f447323e65ca571a6eb74fd68dd /astroid/modutils.py
parentd4d1842ed2c3b51de80869ad0b423f11b1937987 (diff)
downloadastroid-git-d65e7cd75d368a075ff271c8320e94ebf2f2d9b1.tar.gz
Cleanup pylint's warnings over astroid codebase
Some of the messages were disabled in pylintrc, since they're not very useful for our case. Other parameters, such as the number of arguments / statements / attributes etc were configured so that they won't be too restrictive for our codebase, since making the code to respect them right now requires too much development changes, which is not justified by the end result. Closes issue #284.
Diffstat (limited to 'astroid/modutils.py')
-rw-r--r--astroid/modutils.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/astroid/modutils.py b/astroid/modutils.py
index e127d845..749018ca 100644
--- a/astroid/modutils.py
+++ b/astroid/modutils.py
@@ -394,7 +394,7 @@ def get_module_part(dotted_name, context_file=None):
file_from_modpath(parts[starti:i+1], path=path,
context_file=context_file)
except ImportError:
- if not i >= max(1, len(parts) - 2):
+ if i < max(1, len(parts) - 2):
raise
return '.'.join(parts[:i])
return dotted_name
@@ -425,7 +425,7 @@ def get_module_files(src_directory, blacklist, list_all=False):
for directory, dirnames, filenames in os.walk(src_directory):
_handle_blacklist(blacklist, dirnames, filenames)
# check for __init__.py
- if not list_all and not '__init__.py' in filenames:
+ if not list_all and '__init__.py' not in filenames:
dirnames[:] = ()
continue
for filename in filenames:
@@ -581,13 +581,9 @@ def _search_zip(modpath, pic):
filepath)
raise ImportError('No module named %s' % '.'.join(modpath))
-try:
- import pkg_resources
-except ImportError:
- pkg_resources = None
-
def _is_namespace(modname):
+ # pylint: disable=no-member; astroid issue #290, modifying globals at runtime.
return (pkg_resources is not None
and modname in pkg_resources._namespace_packages)
@@ -614,7 +610,7 @@ def _module_file(modpath, path=None):
pic = sys.path_importer_cache
_path = (path is None and sys.path or path)
for __path in _path:
- if not __path in pic:
+ if __path not in pic:
try:
pic[__path] = zipimport.zipimporter(__path)
except zipimport.ZipImportError: