[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 10/16] qapi/expr.py: Remove single-letter variable

From: John Snow
Subject: Re: [PATCH v3 10/16] qapi/expr.py: Remove single-letter variable
Date: Thu, 25 Feb 2021 16:56:52 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

On 2/25/21 9:03 AM, Markus Armbruster wrote:
Why?  Is it to appease a style checker?

I disagree with a blanket ban of single-letter variable names.

If @f is deemed too terrible to live, then I'd prefer @feat over
@feature, because it's more visually distant to @features.

Yeah, pylint. We've changed some of these already and I've had reviews from you, Eduardo and Cleber. I thought there was some consensus, but maybe I misunderstood.

I generally agree that we should avoid single-letter variable names and would like to discourage adding new ones. Loop variables are a bit of a border-case. They're obviously fine in comprehensions.

There's not too many cases left. Mostly it's "for m in members" and "for f in features". We agreed earlier to use "memb" for members. I suppose 'feat' matches.


John Snow <jsnow@redhat.com> writes:

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
  scripts/qapi/expr.py | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index 3235a3b809e..473ee4f7f7e 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -214,14 +214,14 @@ def check_features(features: Optional[object],
          raise QAPISemError(info, "'features' must be an array")
      features[:] = [f if isinstance(f, dict) else {'name': f}
                     for f in features]
-    for f in features:
+    for feature in features:
          source = "'features' member"
-        assert isinstance(f, dict)
-        check_keys(f, info, source, ['name'], ['if'])
-        check_name_is_str(f['name'], info, source)
-        source = "%s '%s'" % (source, f['name'])
-        check_name_str(f['name'], info, source)
-        check_if(f, info, source)
+        assert isinstance(feature, dict)
+        check_keys(feature, info, source, ['name'], ['if'])
+        check_name_is_str(feature['name'], info, source)
+        source = "%s '%s'" % (source, feature['name'])
+        check_name_str(feature['name'], info, source)
+        check_if(feature, info, source)
def check_enum(expr: Expression, info: QAPISourceInfo) -> None:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]