How to avoid Pylint warnings for an inherited class constructor in Python 3?

In Python 3, I have the following code:

class A: def __init__(self): pass class B(A): def __init__(self): super().__init__() 

This gives a warning to Pylint:

  • An old-style class is defined. (Old style class)
  • Using super in old style class (super old)

In my understanding, in Python 3, the old-style class no longer exists, and this code is fine.

Even if I explicitly use new-style classes with this code

 class A(object): def __init__(self): pass class B(A): def __init__(self): super().__init__() 

I get a Pylint warning due to different syntax for calling the parent constructor in Python 3:

  • Missing super () argument (missing-super-argument)

So, how can I tell Pylint that I want to check Python 3 code to avoid these messages (without disabling Pylint check)?

+6
source share
2 answers

This is due to an error in astroid that did not treat all classes as a new w / python 3 style until https://bitbucket.org/logilab/astroid/commits/6869fb2acb9f58f0ba2197c6e9008989d85ca1ca

It should be released shortly.

0
source

According to this list, the "super () argument is missing" has the code E1004 :. If you want to disable only one type of warning, you can add this line to the top of the file:

 # pylint: disable=E1004 

Or you can try calling super() like this:

 class B(A): def __init__(self): super(B, self).__init__() 
+3
source

All Articles