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 for super-init-not-called #4941

Closed
DanielNoord opened this issue Aug 31, 2021 · 2 comments · Fixed by #5698
Closed

False positive for super-init-not-called #4941

DanielNoord opened this issue Aug 31, 2021 · 2 comments · Fixed by #5698
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@DanielNoord
Copy link
Collaborator

DanielNoord commented Aug 31, 2021

Bug description

class A:
    def __init__(self):
        pass


class B(A):
    pass


class D(B, A):
    def __init__(self):
        A.__init__(self)

This was found while working on #4940, after fixing this we might want to check if there are any messages that are unnecessarily disabled in our own codebase.

Command used

pylint test.py

Pylint output

pylint test.py
************* Module test
test.py:11:4: W0231: __init__ method from base class 'B' is not called (super-init-not-called)

------------------------------------------------------------------
Your code has been rated at 8.75/10 (previous run: 8.75/10, +0.00)

Expected behavior

As class B does not have a __init__ it can't be called. The only __init__ included in class B is the __init__ of class A which is being called in class C.

Pylint version

pylint 2.10.3-dev0
astroid 2.7.3
Python 3.9.6 (default, Aug  2 2021, 08:23:35) 
[Clang 12.0.5 (clang-1205.0.22.11)]

OS / Environment

macOS

Additional dependencies

No response

@DanielNoord DanielNoord added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 31, 2021
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 31, 2021
@Goldziher
Copy link

Another example:

class DataclassProtocol(Protocol):
    def __init__(self, **kwargs):  # pylint: disable=super-init-not-called
        ...

    __dataclass_fields__: Dict
    __dataclass_params__: Dict
    __post_init__: Optional[Callable]

@DanielNoord
Copy link
Collaborator Author

DanielNoord commented Jan 18, 2022

@Goldziher Your issue was being tracked in #4790 for which I just created a fix #5697. Should be available in 2.13 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants