pylint

pylint complaining about missing mandatory keyword arguments


Version Info:

(.venv-3.12) % ~/.venv-3.12/bin/pylint --version 
pylint 3.3.1
astroid 3.3.5
Python 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)]

Simple example:

"""kwargs module"""

def fun(a,b,*,c,d,**kwargs):
    """function with kwargs"""
    return a + b + c + d + kwargs['e'] + kwargs['f']

someargs = {}
someargs['c'] = 3
someargs['d'] = 4
someargs['e'] = 5
someargs['f'] = 6
someargs['g'] = 7

rval = fun(1,2,**someargs)
print(rval)

runs fine:

(.venv-3.12) % ~/.venv-3.12/bin/python3 kwargs.py
21

but pylint complains about missing mandatory keyword args:

(.venv-3.12) % ~/.venv-3.12/bin/pylint kwargs.py 
************* Module kwargs
kwargs.py:14:7: E1125: Missing mandatory keyword argument 'c' in function call (missing-kwoa)
kwargs.py:14:7: E1125: Missing mandatory keyword argument 'd' in function call (missing-kwoa)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Is this not legit syntax?


Solution

  • This look like a bug in pylint (as a maintainer of pylint).