Skip to content

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

Open
@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

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

    Development

    No branches or pull requests

    Issue actions