diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-06 19:57:11 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-06 19:57:11 +0300 |
commit | 3ba401db3bd21a91449159b97a438ee23625eadc (patch) | |
tree | 39e271d82e601af6275428f2c668e51ea11ffc9d /pylint/checkers/typecheck.py | |
parent | 7596535e16a1e9cd861aecfb36131c43f0edfe12 (diff) | |
download | pylint-3ba401db3bd21a91449159b97a438ee23625eadc.tar.gz |
Use safe_infer and has_known_bases from astroid.helpers. Closes issue #593.
Diffstat (limited to 'pylint/checkers/typecheck.py')
-rw-r--r-- | pylint/checkers/typecheck.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 8fd0892..d56e66b 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -27,14 +27,13 @@ from astroid import ( ) from astroid.bases import BUILTINS from astroid import objects +from astroid import helpers from pylint.interfaces import IAstroidChecker, INFERENCE, INFERENCE_FAILURE from pylint.checkers import BaseChecker from pylint.checkers.utils import ( - safe_infer, is_super, - check_messages, decorated_with_property, - decorated_with, has_known_bases, - node_ignores_exception) + is_super, check_messages, decorated_with_property, + decorated_with, node_ignores_exception) MSGS = { 'E1101': ('%s %r has no %r member', @@ -130,7 +129,7 @@ def _emit_no_member(node, owner, owner_name, attrname, if isinstance(owner, astroid.Function) and owner.decorators: return False if isinstance(owner, Instance): - if owner.has_dynamic_getattr() or not has_known_bases(owner): + if owner.has_dynamic_getattr() or not helpers.has_known_bases(owner): return False if isinstance(owner, objects.Super): # Verify if we are dealing with an invalid Super object. @@ -141,7 +140,7 @@ def _emit_no_member(node, owner, owner_name, attrname, owner.super_mro() except (MroError, SuperError): return False - if not all(map(has_known_bases, owner.type.mro())): + if not all(map(helpers.has_known_bases, owner.type.mro())): return False # explicit skipping of module member access if owner.root().name in ignored_modules: @@ -356,7 +355,7 @@ accessed. Python regular expressions are accepted.'} """ if not isinstance(node.value, astroid.CallFunc): return - function_node = safe_infer(node.value.func) + function_node = helpers.safe_infer(node.value.func) # skip class, generator and incomplete function definition if not (isinstance(function_node, astroid.Function) and function_node.root().fully_defined()): @@ -394,7 +393,7 @@ accessed. Python regular expressions are accepted.'} # we will not handle them here, right now. expr = node.func.expr - klass = safe_infer(expr) + klass = helpers.safe_infer(expr) if (klass is None or klass is astroid.YES or not isinstance(klass, astroid.Instance)): return @@ -437,7 +436,7 @@ accessed. Python regular expressions are accepted.'} else: num_positional_args += 1 - called = safe_infer(node.func) + called = helpers.safe_infer(node.func) # only function, generator and object defining __call__ are allowed if called is not None and not called.callable(): self.add_message('not-callable', node=node, @@ -594,7 +593,7 @@ accessed. Python regular expressions are accepted.'} # If the types can be determined, only allow indices to be int, # slice or instances with __index__. - parent_type = safe_infer(node.parent.value) + parent_type = helpers.safe_infer(node.parent.value) if not isinstance(parent_type, (astroid.Class, astroid.Instance)): return @@ -636,7 +635,7 @@ accessed. Python regular expressions are accepted.'} if isinstance(node, astroid.ExtSlice): index_type = node else: - index_type = safe_infer(node) + index_type = helpers.safe_infer(node) if index_type is None or index_type is astroid.YES: return @@ -664,7 +663,7 @@ accessed. Python regular expressions are accepted.'} if index is None: continue - index_type = safe_infer(index) + index_type = helpers.safe_infer(index) if index_type is None or index_type is astroid.YES: continue @@ -691,7 +690,7 @@ accessed. Python regular expressions are accepted.'} @check_messages('not-context-manager') def visit_with(self, node): for ctx_mgr, _ in node.items: - infered = safe_infer(ctx_mgr) + infered = helpers.safe_infer(ctx_mgr) if infered is None or infered is astroid.YES: continue @@ -710,7 +709,7 @@ accessed. Python regular expressions are accepted.'} if isinstance(infered, astroid.Instance): # If we do not know the bases of this class, # just skip it. - if not has_known_bases(infered): + if not helpers.has_known_bases(infered): continue # Just ignore mixin classes. if self.config.ignore_mixin_members: |