In Python, many methods define argument variables with "standardized" names, like:
def __exit__(self, type, value, traceback):
In the line above, variable type causes pylint to warn (W0622) that a built-in is being redefined: Redefining built-in 'type' (redefined-builtin).
There are many ways to fix this and make pylint happy (rename the variable, add a pylint directive (# pylint: disable=W0622) to ignore the problem, etc.).
What is the best/preferred/suggested/conventionally-used way (if any) to maintain a good code quality and make pylint happy in these cases?
It could be considered as a bad practise to disable pylint warning.
Quoting quantifiedcode.com :
In order for
__exit__
to work properly it must have exactly three arguments: exception_type, exception_value, and traceback. The formal argument names in the method definition do not need to correspond directly to these names, but they must appear in this order.
As such a good option could be to use tuple packing def __exit__(self, *exc)
This what is suggested in this official documentation: https://docs.python.org/3/library/contextlib.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With