'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 1:[1]
You can disable the warning by using
# noinspection PyArgumentList
on the line before it occurs.
The various possible noinspection
s are not properly documented by JetBrains, which is why I find the following list useful: https://gist.github.com/pylover/7870c235867cf22817ac5b096defb768.
Solution 2:[2]
I was able to silence these on a per-project basis by going to
File > Settings > Editor > Inspections > [search/select: 'Incorrect call arguments']
In the "Severity by Scope" corner, change the scope to "Project Files" and set the severity to "Typo".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Legendre17 |
Solution 2 | vlz |