Desired change
- Rule(s): SIM902
- Adjustment: Should not be applied to
getattr and other alike
Explanation
getattr can't be used with keyword arguments and will throw TypeError: 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, but getattr and other official apis alike should probably be excluded from the rule.
Example

Desired change
getattrand other alikeExplanation
getattrcan't be used with keyword arguments and will throwTypeError: getattr() takes no keyword argumentsif 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, butgetattrand other official apis alike should probably be excluded from the rule.Example