diff options
author | Torsten Marek <shlomme@gmail.com> | 2014-07-24 15:07:51 +0200 |
---|---|---|
committer | Torsten Marek <shlomme@gmail.com> | 2014-07-24 15:07:51 +0200 |
commit | 7aa57622583caab7dc14d0458bc3c4082036b766 (patch) | |
tree | 8235d02ff30784eb6656abedba5daa71fbd8fd22 /checkers/utils.py | |
parent | a7d1515daef1234b3bf3e3991299771bea3c56bc (diff) | |
download | pylint-7aa57622583caab7dc14d0458bc3c4082036b766.tar.gz |
Implement confidence levels.
- attach confidence levels to a number of messages
- include confidence levels in the message object
- if the confidence of a message is not HIGH or UNDEFINED,
include it in the test output.
Diffstat (limited to 'checkers/utils.py')
-rw-r--r-- | checkers/utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/checkers/utils.py b/checkers/utils.py index 000aee7..b3ba51b 100644 --- a/checkers/utils.py +++ b/checkers/utils.py @@ -462,3 +462,22 @@ def is_import_error(handler): return True except astroid.InferenceError: continue + +def has_known_bases(klass): + """Returns true if all base classes of a class could be inferred.""" + try: + return klass._all_bases_known + except AttributeError: + pass + try: + for base in klass.bases: + result = base.infer().next() + # TODO: check for A->B->A->B pattern in class structure too? + if not isinstance(result, astroid.Class) or result is klass or not has_known_bases(result): + klass._all_bases_known = False + return False + except astroid.InferenceError: + klass._all_bases_known = False + return False + klass._all_bases_known = True + return True |