From 50dc38b09a99153e282a5bc1ece85b3fc0a3ab88 Mon Sep 17 00:00:00 2001 From: DudeNr33 <3929834+DudeNr33@users.noreply.github.com> Date: Sun, 3 Apr 2022 18:09:05 +0200 Subject: [PATCH 1/3] Co-authored by: Vladyslav Krylasov Add example for ``bad-super-call`` --- doc/data/messages/b/bad-super-call/bad.py | 7 +++++++ doc/data/messages/b/bad-super-call/details.rst | 4 ++++ doc/data/messages/b/bad-super-call/good.py | 7 +++++++ doc/data/messages/b/bad-super-call/related.rst | 1 + 4 files changed, 19 insertions(+) create mode 100644 doc/data/messages/b/bad-super-call/bad.py create mode 100644 doc/data/messages/b/bad-super-call/details.rst create mode 100644 doc/data/messages/b/bad-super-call/good.py create mode 100644 doc/data/messages/b/bad-super-call/related.rst 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..a6b169c430 --- /dev/null +++ b/doc/data/messages/b/bad-super-call/bad.py @@ -0,0 +1,7 @@ +class Foo: + pass + + +class Bar(Foo): + def __init__(self): + super(Foo, 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..1864663846 --- /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 the own class and ``self`` as arguments (``super(Bar, self)``), which can +lead to a mix up of parent and child class in the code. + +In Python 3 the recommended way is to user ``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..e5c1a2a06b --- /dev/null +++ b/doc/data/messages/b/bad-super-call/good.py @@ -0,0 +1,7 @@ +class Foo: + pass + + +class Bar(Foo): + 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() `_ From dbe9773b923ec9c46429b3a60fe4f172eeb4b05a Mon Sep 17 00:00:00 2001 From: Andreas Finkler <3929834+DudeNr33@users.noreply.github.com> Date: Sun, 3 Apr 2022 18:36:24 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Jacob Walls --- doc/data/messages/b/bad-super-call/details.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/data/messages/b/bad-super-call/details.rst b/doc/data/messages/b/bad-super-call/details.rst index 1864663846..9f02b08560 100644 --- a/doc/data/messages/b/bad-super-call/details.rst +++ b/doc/data/messages/b/bad-super-call/details.rst @@ -1,4 +1,4 @@ -In Python 2.7, ``super()`` has to be called with the own class and ``self`` as arguments (``super(Bar, self)``), which can +In Python 2.7, ``super()`` has to be called with its own class and ``self`` as arguments (``super(Bar, self)``), which can lead to a mix up of parent and child class in the code. -In Python 3 the recommended way is to user ``super()`` without arguments (see also ``super-with-arguments``). +In Python 3 the recommended way is to call ``super()`` without arguments (see also ``super-with-arguments``). From 12e1589d0bed98a9cabf8e183a90ae3aa67f44a2 Mon Sep 17 00:00:00 2001 From: Andreas Finkler <3929834+DudeNr33@users.noreply.github.com> Date: Sun, 3 Apr 2022 19:40:11 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Pierre Sassoulas --- doc/data/messages/b/bad-super-call/bad.py | 6 +++--- doc/data/messages/b/bad-super-call/details.rst | 2 +- doc/data/messages/b/bad-super-call/good.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/data/messages/b/bad-super-call/bad.py b/doc/data/messages/b/bad-super-call/bad.py index a6b169c430..1f13df5ede 100644 --- a/doc/data/messages/b/bad-super-call/bad.py +++ b/doc/data/messages/b/bad-super-call/bad.py @@ -1,7 +1,7 @@ -class Foo: +class Animal: pass -class Bar(Foo): +class Cat(Animal): def __init__(self): - super(Foo, self).__init__() # [bad-super-call] + 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 index 9f02b08560..73f41942c1 100644 --- a/doc/data/messages/b/bad-super-call/details.rst +++ b/doc/data/messages/b/bad-super-call/details.rst @@ -1,4 +1,4 @@ -In Python 2.7, ``super()`` has to be called with its own class and ``self`` as arguments (``super(Bar, self)``), which can +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 index e5c1a2a06b..720b2eda91 100644 --- a/doc/data/messages/b/bad-super-call/good.py +++ b/doc/data/messages/b/bad-super-call/good.py @@ -1,7 +1,7 @@ -class Foo: +class Animal: pass -class Bar(Foo): +class Cat(Animal): def __init__(self): super().__init__()