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 positional-only-arguments-expected #8555

Closed
mbyrnepr2 opened this issue Apr 8, 2023 · 0 comments · Fixed by #8556 or #9093
Closed

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

mbyrnepr2 opened this issue Apr 8, 2023 · 0 comments · Fixed by #8556 or #9093
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@mbyrnepr2
Copy link
Member

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

@mbyrnepr2 mbyrnepr2 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 8, 2023
@mbyrnepr2 mbyrnepr2 self-assigned this Apr 8, 2023
@mbyrnepr2 mbyrnepr2 added this to the 2.17.3 milestone Apr 8, 2023
@jacobtylerwalls jacobtylerwalls added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
2 participants