[PATCH 6/8] python: allow short names for variables on older pylint

John Snow posted 8 patches 3 months ago
[PATCH 6/8] python: allow short names for variables on older pylint
Posted by John Snow 3 months ago
Pylint >= 3.0.0 disabled this feature, but older pylint does not: allow
short names by default by using a regex to do so.

Incidentally, this removes the need for most of the allow list we had before, so
remove most of that, too.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/setup.cfg | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/python/setup.cfg b/python/setup.cfg
index 72b58c98c99..58dba90f815 100644
--- a/python/setup.cfg
+++ b/python/setup.cfg
@@ -148,17 +148,11 @@ disable=consider-using-f-string,
 
 [pylint.basic]
 # Good variable names which should always be accepted, separated by a comma.
-good-names=i,
-           j,
-           k,
-           ex,
-           Run,
-           _,   # By convention: Unused variable
-           fh,  # fh = open(...)
-           fd,  # fd = os.open(...)
-           c,   # for c in string: ...
-           T,   # for TypeVars. See pylint#3401
-           SocketAddrT,  # Not sure why this is invalid.
+good-names=SocketAddrT,  # Not sure why this is invalid.
+
+# pylint < 3.0 warns by default on short variable names.
+# Disable this for older versions.
+good-names-rgxs=^[_a-z][_a-z0-9]?$
 
 [pylint.similarities]
 # Ignore imports when computing similarities.
-- 
2.45.0