diff --git a/doc/data/messages/b/bad-super-call/bad.py b/doc/data/messages/b/bad-super-call/bad.py new file mode 100644 index 0000000000..1f13df5ede --- /dev/null +++ b/doc/data/messages/b/bad-super-call/bad.py @@ -0,0 +1,7 @@ +class Animal: + pass + + +class Cat(Animal): + def __init__(self): + super(Animal, self).__init__() # [bad-super-call] diff --git a/doc/data/messages/b/bad-super-call/details.rst b/doc/data/messages/b/bad-super-call/details.rst new file mode 100644 index 0000000000..73f41942c1 --- /dev/null +++ b/doc/data/messages/b/bad-super-call/details.rst @@ -0,0 +1,4 @@ +In Python 2.7, ``super()`` has to be called with its own class and ``self`` as arguments (``super(Cat, self)``), which can +lead to a mix up of parent and child class in the code. + +In Python 3 the recommended way is to call ``super()`` without arguments (see also ``super-with-arguments``). diff --git a/doc/data/messages/b/bad-super-call/good.py b/doc/data/messages/b/bad-super-call/good.py new file mode 100644 index 0000000000..720b2eda91 --- /dev/null +++ b/doc/data/messages/b/bad-super-call/good.py @@ -0,0 +1,7 @@ +class Animal: + pass + + +class Cat(Animal): + def __init__(self): + super().__init__() diff --git a/doc/data/messages/b/bad-super-call/related.rst b/doc/data/messages/b/bad-super-call/related.rst new file mode 100644 index 0000000000..5189197dd0 --- /dev/null +++ b/doc/data/messages/b/bad-super-call/related.rst @@ -0,0 +1 @@ +- `Documentation for super() `_