Skip to content

False positive for positional-only-arguments-expected #8555

@mbyrnepr2

Description

@mbyrnepr2

Bug description

a.py:

def function_with_kwargs(apple, banana="Yellow banana", /, **kwargs):
    """
    Calling this function with the `banana` keyword should not emit
    `positional-only-arguments-expected` since it is added to `**kwargs`.

    >>> function_with_kwargs("Red apple", banana="Green banana")
    >>> "Red apple"
    >>> "Yellow banana"
    >>> {"banana": "Green banana"}
    """
    print(apple)
    print(banana)
    print(kwargs)

Configuration

No response

Command used

pylint a.py

Pylint output

a.py:15:0: E3102: `function_with_kwargs()` got some positional-only arguments passed as keyword arguments: 'banana' (positional-only-arguments-expected)

Expected behavior

No error emitted in this case as the argument passed to the function is part of **kwargs.
The purpose of this checker is to indicate when an error would occur at runtime, for example:
TypeError: function_with_kwargs() got some positional-only arguments passed as keyword arguments: 'banana'.

However, in this case, there is no error running this Python code.

Pylint version

pylint 3.0.0b1
astroid 2.16.0dev0
Python 3.10.4

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions