summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Johnson <johnsomor@gmail.com>2021-11-30 00:20:52 +0000
committerMichael Johnson <johnsomor@gmail.com>2021-11-30 00:22:51 +0000
commit256f889279625420b3d430bcf0a2bdd62f679a6c (patch)
tree98371efd64c52bdae69a6963a192ac882ffd274c
parentacd930d3429aa30bea449f5fc7246581b0d2eb25 (diff)
downloaddesignate-256f889279625420b3d430bcf0a2bdd62f679a6c.tar.gz
Add hacking check D710 for LOG.warn()
Python 3 deprecated the logger.warn method, see: https://docs.python.org/3/library/logging.html#logging.warning so we prefer to use warning to avoid DeprecationWarning. This patch adds a hacking check, similar to other projects, that enforces using LOG.warning() instead of LOG.warn(). Change-Id: I424ccc14ec09dd6c7662aaee1096dfd56917aef2
-rw-r--r--designate/hacking/checks.py11
-rw-r--r--tox.ini1
2 files changed, 12 insertions, 0 deletions
diff --git a/designate/hacking/checks.py b/designate/hacking/checks.py
index 752dc9d7..0a3a6c2d 100644
--- a/designate/hacking/checks.py
+++ b/designate/hacking/checks.py
@@ -26,6 +26,7 @@ import pycodestyle
# D707: basestring is not Python3-compatible, use str instead.
# D708: Do not use xrange. Use range for large loops.
# D709: LOG.audit is deprecated, please use LOG.info!
+# D710: LOG.warn() is not allowed. Use LOG.warning()
UNDERSCORE_IMPORT_FILES = []
@@ -150,3 +151,13 @@ def check_no_log_audit(logical_line):
"""
if "LOG.audit(" in logical_line:
yield(0, "D709: LOG.audit is deprecated, please use LOG.info!")
+
+
+@core.flake8ext
+def check_no_log_warn(logical_line):
+ """Disallow 'LOG.warn('
+
+ D710
+ """
+ if logical_line.startswith('LOG.warn('):
+ yield(0, "D710:Use LOG.warning() rather than LOG.warn()")
diff --git a/tox.ini b/tox.ini
index c37102a4..0d20e4f4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -177,6 +177,7 @@ extension =
D707 = checks:check_no_basestring
D708 = checks:check_python3_xrange
D709 = checks:check_no_log_audit
+ D710 = checks:check_no_log_warn
paths = ./designate/hacking
[testenv:lower-constraints]