Skip to content

[too-many-function-args] False negative when calling super().__init__() with non-self argument #9519

@da-dada

Description

@da-dada

Bug

no error given in pylint, no run in Python

class WinHlp:

    def print_text(self, txt):
        print(f'{__class__} {txt=}')

class Window:

    def print_text(self, txt):
        print(f'{__class__} {txt=}')

class Win(WinHlp, Window):
    def __init__(self, txt):
        super().__init__(txt)

        self.print_text(txt)

Win('hello')

Configuration

No response

Command used

pylint a.py

Pylint output

Microsoft Windows [Version 10.0.19045.4170]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Me>cd C:\Users\Me\Documents\Programming\Python\Mylib\experimental\subclassing\more than 1 base\discussions

C:\Users\Me\Documents\Programming\Python\Mylib\experimental\subclassing\more than 1 base\discussions>pylint test.py
************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:1:0: C0115: Missing class docstring (missing-class-docstring)
test.py:3:4: C0116: Missing function or method docstring (missing-function-docstring)
test.py:1:0: R0903: Too few public methods (1/2) (too-few-public-methods)
test.py:6:0: C0115: Missing class docstring (missing-class-docstring)
test.py:8:4: C0116: Missing function or method docstring (missing-function-docstring)
test.py:6:0: R0903: Too few public methods (1/2) (too-few-public-methods)
test.py:11:0: C0115: Missing class docstring (missing-class-docstring)
test.py:11:0: R0903: Too few public methods (1/2) (too-few-public-methods)

------------------------------------------------------------------
Your code has been rated at 1.82/10 (previous run: 8.82/10, -7.00)


C:\Users\Me\Documents\Programming\Python\Mylib\experimental\subclassing\more than 1 base\discussions>

Expected behavior

Microsoft Windows [Version 10.0.19045.4170]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Me>cd C:\Users\Me\Documents\Programming\Python\Mylib\experimental\subclassing\more than 1 base\discussions

C:\Users\Me\Documents\Programming\Python\Mylib\experimental\subclassing\more than 1 base\discussions>test.py
Traceback (most recent call last):
File "C:\Users\Me\Documents\Programming\Python\Mylib\experimental\subclassing\more than 1 base\discussions\test.py", l
ine 17, in
Win('hello')
File "C:\Users\Me\Documents\Programming\Python\Mylib\experimental\subclassing\more than 1 base\discussions\test.py", l
ine 13, in init
super().init(txt)
TypeError: object.init() takes exactly one argument (the instance to initialize)

C:\Users\Me\Documents\Programming\Python\Mylib\experimental\subclassing\more than 1 base\discussions>

Pylint version

pylint 3.1.0
astroid 3.1.0
Python 3.12.2

OS / Environment

Windows 10

Additional dependencies

No response

Activity

added
Needs triage 📥Just created, needs acknowledgment, triage, and proper labelling
on Mar 24, 2024
jacobtylerwalls

jacobtylerwalls commented on Mar 24, 2024

@jacobtylerwalls
Member

Thanks for the report!

Slimmer reproducer without multiple bases:

class Window:
    ...

class Win(Window):
    def __init__(self, txt):
        super().__init__(txt)

Win('hello')

EDIT: removed incorrect hint.

added
Good first issueFriendly and approachable by new contributors
False Negative 🦋No message is emitted but something is wrong with the code
and removed
Needs triage 📥Just created, needs acknowledgment, triage, and proper labelling
on Mar 24, 2024
changed the title [-]subclassing[/-] [+][no-value-for-parameter] False negative when calling `super().__init__()` with non-self argument[/+] on Mar 24, 2024
added
Needs PRThis issue is accepted, sufficiently specified and now needs an implementation
on Mar 24, 2024
shekhuverma

shekhuverma commented on Apr 16, 2024

@shekhuverma

I am looking to solve this one but I am not able to get how to add this condition to the above mentioned code block?

changed the title [-][no-value-for-parameter] False negative when calling `super().__init__()` with non-self argument[/-] [+][too-many-function-args] False negative when calling `super().__init__()` with non-self argument[/+] on Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Negative 🦋No message is emitted but something is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @shekhuverma@jacobtylerwalls@da-dada

      Issue actions

        [too-many-function-args] False negative when calling `super().__init__()` with non-self argument · Issue #9519 · pylint-dev/pylint