Flag E1101 astng inference failures From: Daniel Drake This is a partial workaround for #3216 in that it raises a different E1101 message when astng was unable to infer all possible object types. This allows the potentially bogus errors to be separated from the known errors. Index: pylint-0.12.2/checkers/typecheck.py =================================================================== --- pylint-0.12.2.orig/checkers/typecheck.py +++ pylint-0.12.2/checkers/typecheck.py @@ -28,6 +28,10 @@ MSGS = { 'E1102': ('%s is not callable', 'Used when an object being called has been infered to a non \ callable object'), + 'E1103': ('%s %r has no %r member but some types could not be inferred', + 'Used when a class is accessed for an unexistant member, but \ + astng was not able to interpret all possible types of this \ + class.'), 'E1111': ('Assigning to function call which doesn\'t return', 'Used when an assigment is done on a function call but the \ infered function doesn\'t return anything.'), @@ -91,9 +95,12 @@ zope\'s acquisition mecanism and so shou # list of (node, nodename) which are missing the attribute missingattr = set() ignoremim = self.config.ignore_mixin_members + inference_failure = False for owner in infered: # skip yes object if owner is astng.YES: + # but record the fact that we couldn't infer all types + inference_failure = True continue # if there is ambiguity, skip None if len(infered) > 1 and isinstance(owner, astng.Const) \ @@ -134,7 +141,11 @@ zope\'s acquisition mecanism and so shou if actual in done: continue done.add(actual) - self.add_message('E1101', node=node, + if inference_failure: + msg = 'E1103' + else: + msg = 'E1101' + self.add_message(msg, node=node, args=(display_type(owner), name, node.attrname))