Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive: useless-parent-delegation on '__init__' method of class derived from 'Exception' #9994

Open
dnpetrov opened this issue Oct 1, 2024 · 0 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@dnpetrov
Copy link

dnpetrov commented Oct 1, 2024

Bug description

useless-parent-delegation is reported on '__init__' method of class derived from 'Exception'.
This '__init__' method, though, accepts no arguments except for 'self'.
For regular classes following the same pattern (base class '__init__' accepts arbitrary additional arguments, derived class '__init__' accepts only 'self'), no warning is reported.

a.py:

class Base:
    def __init__(self, *args, **kwargs):
        pass


class Derived(Base):
    # No warning
    def __init__(self):
        super().__init__()


class MyException(Exception):
    # W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
    def __init__(self):
        super().__init__()


### Configuration

_No response_

### Command used

```shell
pylint a.py

Pylint output

************* Module a
a.py:14:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)

Expected behavior

No warning for MyException 'init'.

Pylint version

pylint 3.2.5
astroid 3.2.3
Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]

OS / Environment

Ubuntu 22.04.4

Additional dependencies

No response

@dnpetrov dnpetrov added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

1 participant