Search code examples
pythonpycharmpython-dataclasses

How can I silence a PyCharm "Unexpected argument" message for simple, indirect object creation


I am getting an "Unexpected argument" message with Python 3.7 and PyCharm 2020.2 when using the code below.

from dataclasses import dataclass


@dataclass
class Foo(object):
    x: int
    y: str
        
        
arg_dict = {'x': 1, 'y': 'bar'}

the_class = Foo

a = Foo(**arg_dict)

b = the_class(**arg_dict)

How can I prevent it or silence it?


Solution

  • You can disable the warning by using

    # noinspection PyArgumentList
    

    on the line before it occurs.

    The various possible noinspections are not properly documented by JetBrains, which is why I find the following list useful: https://gist.github.com/pylover/7870c235867cf22817ac5b096defb768.