diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-22 23:30:39 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-22 23:30:39 +0300 |
commit | 86bd8ca44e3122f7bf722d5efa25d5237097eef1 (patch) | |
tree | a51820764b30df67d6598c4b2987aea79900f4c5 | |
parent | a1e4d2e8ae637d6c2f760dde60b38c3d8bb3269f (diff) | |
download | pylint-86bd8ca44e3122f7bf722d5efa25d5237097eef1.tar.gz |
Don't emit no-init if not all the bases from a class are known.
Closes issue #604.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/checkers/classes.py | 2 | ||||
-rw-r--r-- | pylint/test/functional/init_not_called.py | 7 |
3 files changed, 10 insertions, 3 deletions
@@ -222,7 +222,9 @@ ChangeLog for Pylint * Improve detection of relative imports in non-packages, as well as importing missing modules with a relative import from a package. - + + * Don't emit no-init if not all the bases from a class are known. + Closes issue #604. diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index c4f7ff0..edbc36b 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -307,7 +307,7 @@ a metaclass class method.'} self._accessed.append(defaultdict(list)) self._check_bases_classes(node) # if not an exception or a metaclass - if node.type == 'class': + if node.type == 'class' and helpers.has_known_bases(node): try: node.local_attr('__init__') except astroid.NotFoundError: diff --git a/pylint/test/functional/init_not_called.py b/pylint/test/functional/init_not_called.py index e22be39..43629c7 100644 --- a/pylint/test/functional/init_not_called.py +++ b/pylint/test/functional/init_not_called.py @@ -1,4 +1,4 @@ -# pylint: disable=R0903 +# pylint: disable=R0903,import-error, missing-docstring """test for __init__ not called """ from __future__ import print_function @@ -57,3 +57,8 @@ class AssignedInit(NewStyleC): """No init called.""" def __init__(self): # [super-init-not-called] self.arg = 0 + +from missing import Missing + +class UnknownBases(Missing): + """Don't emit no-init if the bases aren't known.""" |