-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
unexpected-keyword-arg in dataclasses with kw_only=True, inheritance and defaults #6550
Comments
+1. So for now we are disabling the linter on every instantiation. |
+1 We really need the feature too.
We do the same things. It freaks me out. |
Fixed with in pylint-dev/astroid#1764 @jacobtylerwalls Do we want test for this and for the original issue that that PR targeted in |
Let's merge at least one test case in pylint, since the astroid one is a little convoluted (on purpose, to catch the string contains issue.) |
Sure! I'll open a PR for you to review 😄 |
I am experiencing the same issue even when i dont use default values and I even tried defining my own init function: @dataclass(kw_only=True)
class Alert:
"""of alerts"""
alert_type: str
location: torch.Tensor
# score: float = 1.
def __init__(self, **kwargs):
for k, v in kwargs.items():
if k != 'self':
setattr(self, k, v)
@dataclass(kw_only=True)
class RoofingAlert(Alert):
# type = 'roofing'
# location: torch.Tensor
angle: float
cath_direction: torch.Tensor
vess_direction: torch.Tensor
def __init__(self, **kwargs):
super().__init__(alert_type=kwargs.get('alert_type'), location=kwargs.get('location'))
for k, v in kwargs.items():
if k != 'self':
setattr(self, k, v) and the error:
|
Hello and thank you for reporting an issue @yarinbar. Could you open a new issue, this one is closed and the comment is going to get lost. |
Bug description
This is practically #6275 when using the new kw_only=True
The following code causes the bogus error. The key points are:
The problem doesn't happen if there's no default in-between or if inheritance isn't used.
Command used
Pylint output
Expected behavior
No pylint errors. This is valid code.
Pylint version
OS / Environment
The text was updated successfully, but these errors were encountered: