warn is called on a logger, an old alias of warning that is deprecated

tx0/python:deprecated-logger-warnrecommendedwarningsmell

What it finds

Logger.warn and logging.warn are deprecated aliases of warning and print a DeprecationWarning; Python 3.13 removed logging.warn. Reported are calls of warn on the module logging and on names and attributes that contain log, such as logger or self.log; warnings.warn is a different function and is not affected. The fix renames the call and is safe.

From the rule's source, deprecated_logger_warn.rs.

Example from the rule's tests
import loggingimport warnings logger = logging.getLogger(__name__)logging.warn("old")tx0 reports: warn is a deprecated alias of warninglogger.warn("old")tx0 reports: warn is a deprecated alias of warningwarnings.warn("fine")logger.warning("fine")
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:deprecated-logger-warn" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

# tx0: ignore[tx0/python:deprecated-logger-warn] reason="..."

tx0 explain tx0/python:deprecated-logger-warn shows the same in the terminal. Found a false positive? Report it.