Closed bellini666 closed 2 years ago
Get the same error with self.multiple = kwargs.pop('multiple', True)
line.
Thank you, I'll fix it immediately for those examples. However, positional-only arguments might be a reason to remove this rule completely :smiling_face_with_tear:
Full minimal example:
from dataclasses import dataclass
@dataclass
class Point:
x: int
y: int
p = Point(1, 2)
print(getattr(p, "x", default="foo"))
With the current way I receive the AST there is no practical way to detect positional-only arguments. I moved the rule to https://github.com/MartinThoma/flake8-scream as that project is allowed to have false-positives.
Desired change
getattr
and other alikeExplanation
getattr
can't be used with keyword arguments and will throwTypeError: getattr() takes no keyword arguments
if tried to be used as such.The same applies to functions defined as as positional only (by using
/
in the arguments), which might make it impossible to use keyword arguments. This case is not easy to workaround though, butgetattr
and other official apis alike should probably be excluded from the rule.Example