pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.32k stars 1.14k forks source link

unexpected-keyword-arg: false positive and confusing error message with Uninferable #9983

Open dseomn opened 1 month ago

dseomn commented 1 month ago

Bug description

This code is triggering unexpected-keyword-arg, I think because pylint can't infer the value of name:

https://github.com/dseomn/rock-paper-sand/blob/b0cf620cee0cd118eb1b7ee34d15f9257d0fb3be/rock_paper_sand/media_filter_test.py#L391

registry = media_filter.Registry(**{f"{name}_factory": factory})

Configuration

No response

Command used

pylint rock_paper_sand

Pylint output

rock_paper_sand/media_filter_test.py:391:19: E1123: Unexpected keyword argument 'Uninferable_factory' in constructor call (unexpected-keyword-arg)

Expected behavior

Since pylint can't tell if the keyword arg is valid or not, I'd expect it to not complain.

Even if it does have a finding for this, the 'Uninferable_factory' in the error message is confusing, since (as far as I can tell) it's a combination of a value supplied by pylint (Uninferable) and the f-string in the code, but the actual code would never have a keyword arg with the name Uninferable_factory.

Pylint version

https://github.com/dseomn/rock-paper-sand/actions/runs/11061313391/job/30733661830 shows pylint 3.3.1, astroid 3.3.4, and python 3.12.6.

OS / Environment

No response

Additional dependencies

No response