summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-06-14 08:41:46 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-06-14 08:43:14 +0200
commiteaef0dbedb32ea9540505db6450454b5e8dbd10b (patch)
tree71386933c984e146360ec5b70388d3843baf95c8
parentc2b9488f0b38c2a18b21b1926bc1228abffed3c5 (diff)
downloadastroid-git-eaef0dbedb32ea9540505db6450454b5e8dbd10b.tar.gz
Fix lint errors
-rw-r--r--astroid/brain/brain_pkg_resources.py2
-rw-r--r--astroid/interpreter/_import/util.py1
-rw-r--r--astroid/manager.py7
-rw-r--r--astroid/node_classes.py2
-rw-r--r--astroid/scoped_nodes.py4
-rw-r--r--astroid/tests/unittest_manager.py15
-rw-r--r--astroid/tests/unittest_raw_building.py2
-rw-r--r--astroid/tests/unittest_scoped_nodes.py7
8 files changed, 12 insertions, 28 deletions
diff --git a/astroid/brain/brain_pkg_resources.py b/astroid/brain/brain_pkg_resources.py
index bd60ecd3..bb31b0f9 100644
--- a/astroid/brain/brain_pkg_resources.py
+++ b/astroid/brain/brain_pkg_resources.py
@@ -64,6 +64,8 @@ def cleanup_resources(force=False):
def get_distribution(dist):
return Distribution(dist)
+
+_namespace_packages = {}
''')
diff --git a/astroid/interpreter/_import/util.py b/astroid/interpreter/_import/util.py
index 79ff4e0a..3968ef9a 100644
--- a/astroid/interpreter/_import/util.py
+++ b/astroid/interpreter/_import/util.py
@@ -7,6 +7,5 @@ except ImportError:
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)
diff --git a/astroid/manager.py b/astroid/manager.py
index 4e7e35d0..243384b2 100644
--- a/astroid/manager.py
+++ b/astroid/manager.py
@@ -112,16 +112,13 @@ class AstroidManager(object):
os.chdir(os.path.dirname(context_file))
try:
found_spec = self.file_from_module_name(modname, context_file)
- # pylint: disable=no-member
if found_spec.type == spec.ModuleType.PY_ZIPMODULE:
- # pylint: disable=no-member
module = self.zip_import_data(found_spec.location)
if module is not None:
return module
elif found_spec.type in (spec.ModuleType.C_BUILTIN,
spec.ModuleType.C_EXTENSION):
- # pylint: disable=no-member
if (found_spec.type == spec.ModuleType.C_EXTENSION
and not self._can_load_extension(modname)):
return self._build_stub_module(modname)
@@ -136,21 +133,17 @@ class AstroidManager(object):
elif found_spec.type == spec.ModuleType.PY_COMPILED:
raise exceptions.AstroidImportError(
"Unable to load compiled module {modname}.",
- # pylint: disable=no-member
modname=modname, path=found_spec.location)
elif found_spec.type == spec.ModuleType.PY_NAMESPACE:
return self._build_namespace_module(modname,
- # pylint: disable=no-member
found_spec.submodule_search_locations)
- # pylint: disable=no-member
if found_spec.location is None:
raise exceptions.AstroidImportError(
"Can't find a file for module {modname}.",
modname=modname)
- # pylint: disable=no-member
return self.ast_from_file(found_spec.location, modname, fallback=False)
except exceptions.AstroidBuildingError as e:
for hook in self._failed_import_hooks:
diff --git a/astroid/node_classes.py b/astroid/node_classes.py
index 3c7418f3..dcff3692 100644
--- a/astroid/node_classes.py
+++ b/astroid/node_classes.py
@@ -636,7 +636,7 @@ class NodeNG(object):
for matching in child_node.nodes_of_class(klass, skip_klass):
yield matching
- def _infer_name(self, frame, name): #pylint: disable=useless-return
+ def _infer_name(self, frame, name):
# overridden for ImportFrom, Import, Global, TryExcept and Arguments
return None
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index 74db78b8..be4483fe 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -536,7 +536,7 @@ class Module(LocalsDictNodeNG):
"""
return self
- def previous_sibling(self): #pylint: disable=useless-return
+ def previous_sibling(self):
"""The previous sibling statement.
:returns: The previous sibling statement node.
@@ -544,7 +544,7 @@ class Module(LocalsDictNodeNG):
"""
return
- def next_sibling(self): #pylint: disable=useless-return
+ def next_sibling(self):
"""The next sibling statement node.
:returns: The next sibling statement node.
diff --git a/astroid/tests/unittest_manager.py b/astroid/tests/unittest_manager.py
index 2b5258fe..34bb415b 100644
--- a/astroid/tests/unittest_manager.py
+++ b/astroid/tests/unittest_manager.py
@@ -125,7 +125,7 @@ class AstroidManagerTest(resources.SysPathSetup,
def test_namespace_package_pth_support(self):
pth = 'foogle_fax-0.12.5-py2.7-nspkg.pth'
site.addpackage(resources.RESOURCE_PATH, pth, [])
- pkg_resources._namespace_packages['foogle'] = [] # pylint: disable=no-member
+ pkg_resources._namespace_packages['foogle'] = []
try:
module = self.manager.ast_from_module_name('foogle.fax')
@@ -135,18 +135,18 @@ class AstroidManagerTest(resources.SysPathSetup,
with self.assertRaises(exceptions.AstroidImportError):
self.manager.ast_from_module_name('foogle.moogle')
finally:
- del pkg_resources._namespace_packages['foogle'] # pylint: disable=no-member
+ del pkg_resources._namespace_packages['foogle']
sys.modules.pop('foogle')
def test_nested_namespace_import(self):
pth = 'foogle_fax-0.12.5-py2.7-nspkg.pth'
site.addpackage(resources.RESOURCE_PATH, pth, [])
- pkg_resources._namespace_packages['foogle'] = ['foogle.crank'] # pylint: disable=no-member
- pkg_resources._namespace_packages['foogle.crank'] = [] # pylint: disable=no-member
+ pkg_resources._namespace_packages['foogle'] = ['foogle.crank']
+ pkg_resources._namespace_packages['foogle.crank'] = []
try:
self.manager.ast_from_module_name('foogle.crank')
finally:
- del pkg_resources._namespace_packages['foogle'] # pylint: disable=no-member
+ del pkg_resources._namespace_packages['foogle']
sys.modules.pop('foogle')
def test_namespace_and_file_mismatch(self):
@@ -155,12 +155,12 @@ class AstroidManagerTest(resources.SysPathSetup,
self.assertEqual(ast.name, 'unittest')
pth = 'foogle_fax-0.12.5-py2.7-nspkg.pth'
site.addpackage(resources.RESOURCE_PATH, pth, [])
- pkg_resources._namespace_packages['foogle'] = [] # pylint: disable=no-member
+ pkg_resources._namespace_packages['foogle'] = []
try:
with self.assertRaises(exceptions.AstroidImportError):
self.manager.ast_from_module_name('unittest.foogle.fax')
finally:
- del pkg_resources._namespace_packages['foogle'] # pylint: disable=no-member
+ del pkg_resources._namespace_packages['foogle']
sys.modules.pop('foogle')
def _test_ast_from_zip(self, archive):
@@ -207,7 +207,6 @@ class AstroidManagerTest(resources.SysPathSetup,
"""check if the unittest filepath is equals to the result of the method"""
self.assertEqual(
_get_file_from_object(unittest),
- # pylint: disable=no-member; can't infer the ModuleSpec
self.manager.file_from_module_name('unittest', None).location)
def test_file_from_module_name_astro_building_exception(self):
diff --git a/astroid/tests/unittest_raw_building.py b/astroid/tests/unittest_raw_building.py
index 6237c989..f5b4af38 100644
--- a/astroid/tests/unittest_raw_building.py
+++ b/astroid/tests/unittest_raw_building.py
@@ -46,14 +46,12 @@ class RawBuildingTC(unittest.TestCase):
def test_build_function_args(self):
args = ['myArgs1', 'myArgs2']
- # pylint: disable=no-member; not aware of postinit
node = build_function('MyFunction', args)
self.assertEqual('myArgs1', node.args.args[0].name)
self.assertEqual('myArgs2', node.args.args[1].name)
self.assertEqual(2, len(node.args.args))
def test_build_function_defaults(self):
- # pylint: disable=no-member; not aware of postinit
defaults = ['defaults1', 'defaults2']
node = build_function('MyFunction', None, defaults)
self.assertEqual(2, len(node.args.defaults))
diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py
index af2a774b..2b6355e7 100644
--- a/astroid/tests/unittest_scoped_nodes.py
+++ b/astroid/tests/unittest_scoped_nodes.py
@@ -229,13 +229,6 @@ class ModuleNodeTest(ModuleLoader, unittest.TestCase):
with astroid.stream() as stream:
self.assertEqual(stream.read(), file_io.read())
- def test_file_stream_api(self):
- path = resources.find('data/all.py')
- astroid = builder.AstroidBuilder().file_build(path, 'all')
- with self.assertRaises(AttributeError):
- # pylint: disable=pointless-statement
- astroid.file_stream
-
def test_stream_api(self):
path = resources.find('data/all.py')
astroid = builder.AstroidBuilder().file_build(path, 'all')