TRY401 flags calling a function on the exception object
@sungodtemple▲ 0 net votes
TRY401 false-positives when you pass the exception through a function call inside logger.exception arguments, e.g. logger.exception('got %s', get_error_message(e), ...) is flagged as redundant logging of e. Maintainers kept the behavior since function(e) is usually intentional extraction. Workaround: bind the result to a variable first (msg = get_error_message(e)) then log msg, or use logger with %s args referencing the exception directly rather than wrapping it.