Skip to contentSkip to conversation

scripts/qapi: minor delinting

PATCH Applied John Snow 2 participants 4 messages Feb 11, 2022 – Feb 23, 2022

lore
Share & tools
lore

John Snow

author
#0 lore raw

PATCH v2 1/1 scripts/qapi: minor delinting

Get isort and pylint tools passing again.

---
 scripts/qapi/commands.py |  2 +-
 scripts/qapi/pylintrc    | 15 +++++----------
 scripts/qapi/types.py    |  6 +++++-
 scripts/qapi/visit.py    |  6 +++++-
 4 files changed, 16 insertions(+), 13 deletions(-)
scripts/qapi/commands.py +1 -1
index 869d799ed22..38ca38a7b9d 100644
@@ -25,8 +25,8 @@
     QAPIGenC,
     QAPISchemaModularCVisitor,
     build_params,
-    ifcontext,
     gen_special_features,
+    ifcontext,
 )
 from .schema import (
     QAPISchema,
scripts/qapi/pylintrc +5 -10
index b259531a726..1fed2e69620 100644
@@ -34,16 +34,11 @@ disable=fixme,
 
 [BASIC]
 
-# Good variable names which should always be accepted, separated by a comma.
-good-names=i,
-           j,
-           k,
-           ex,
-           Run,
-           _,
-           fp,  # fp = open(...)
-           fd,  # fd = os.open(...)
-           ch,
+# Good variable names regexes, separated by a comma. If names match any regex,
+# they will always be accepted
+
+# Allow just about anything, as per Markus's preference.
+good-names-rgxs=^[_a-z][_a-z0-9]?$
 
 [VARIABLES]
 
scripts/qapi/types.py +5 -1
index 3013329c248..477d0270013 100644
@@ -16,7 +16,11 @@
 from typing import List, Optional
 
 from .common import c_enum_const, c_name, mcgen
-from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext
+from .gen import (
+    QAPISchemaModularCVisitor,
+    gen_special_features,
+    ifcontext,
+)
 from .schema import (
     QAPISchema,
     QAPISchemaEnumMember,
scripts/qapi/visit.py +5 -1
index e13bbe42925..380fa197f58 100644
@@ -21,7 +21,11 @@
     indent,
     mcgen,
 )
-from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext
+from .gen import (
+    QAPISchemaModularCVisitor,
+    gen_special_features,
+    ifcontext,
+)
 from .schema import (
     QAPISchema,
     QAPISchemaEnumMember,
Signature · 1 line
2.34.1
#1 lore raw
Quoted 36 lines · John Snow

Get isort and pylint tools passing again.

---
 scripts/qapi/commands.py |  2 +-
 scripts/qapi/pylintrc    | 15 +++++----------
 scripts/qapi/types.py    |  6 +++++-
 scripts/qapi/visit.py    |  6 +++++-
 4 files changed, 16 insertions(+), 13 deletions(-)
scripts/qapi/commands.py +1 -1
index 869d799ed22..38ca38a7b9d 100644
@@ -25,8 +25,8 @@
     QAPIGenC,
     QAPISchemaModularCVisitor,
     build_params,
-    ifcontext,
     gen_special_features,
+    ifcontext,
 )
 from .schema import (
     QAPISchema,
scripts/qapi/pylintrc +0 -4
index b259531a726..1fed2e69620 100644
@@ -34,16 +34,11 @@ disable=fixme,
 
 [BASIC]
 
-# Good variable names which should always be accepted, separated by a comma.
-good-names=i,
-           j,
-           k,

scripts/qapi/pylintrc disable=fixme, · line 40

Quoted 10 lines
scripts/qapi/pylintrc +4 -6
-           ex,
-           Run,
-           _,
-           fp,  # fp = open(...)
-           fd,  # fd = os.open(...)
-           ch,
+# Good variable names regexes, separated by a comma. If names match any regex,
+# they will always be accepted
+
+# Allow just about anything, as per Markus's preference.

Does it still flag PEP-8 violations like all lower case class names?

If yes, "just about any length" is more precise.

Quoted 38 lines
scripts/qapi/pylintrc +1 -0
+good-names-rgxs=^[_a-z][_a-z0-9]?$
 
 [VARIABLES]
 
scripts/qapi/types.py +5 -1
index 3013329c248..477d0270013 100644
@@ -16,7 +16,11 @@
 from typing import List, Optional
 
 from .common import c_enum_const, c_name, mcgen
-from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext
+from .gen import (
+    QAPISchemaModularCVisitor,
+    gen_special_features,
+    ifcontext,
+)
 from .schema import (
     QAPISchema,
     QAPISchemaEnumMember,
scripts/qapi/visit.py +5 -1
index e13bbe42925..380fa197f58 100644
@@ -21,7 +21,11 @@
     indent,
     mcgen,
 )
-from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext
+from .gen import (
+    QAPISchemaModularCVisitor,
+    gen_special_features,
+    ifcontext,
+)
 from .schema import (
     QAPISchema,
     QAPISchemaEnumMember,
Reviewed-by
#2 lore raw
Quoted 34 lines · Markus Armbruster
Quoted 32 lines · John Snow

Get isort and pylint tools passing again.

---
 scripts/qapi/commands.py |  2 +-
 scripts/qapi/pylintrc    | 15 +++++----------
 scripts/qapi/types.py    |  6 +++++-
 scripts/qapi/visit.py    |  6 +++++-
 4 files changed, 16 insertions(+), 13 deletions(-)
scripts/qapi/commands.py +1 -1
index 869d799ed22..38ca38a7b9d 100644
@@ -25,8 +25,8 @@
     QAPIGenC,
     QAPISchemaModularCVisitor,
     build_params,
-    ifcontext,
     gen_special_features,
+    ifcontext,
 )
 from .schema import (
     QAPISchema,
scripts/qapi/pylintrc +0 -0
index b259531a726..1fed2e69620 100644
@@ -34,16 +34,11 @@ disable=fixme,
 
 [BASIC]
 
Quoted 16 lines
Quoted 4 lines
scripts/qapi/pylintrc +0 -4
-# Good variable names which should always be accepted, separated by a comma.
-good-names=i,
-           j,
-           k,

scripts/qapi/pylintrc disable=fixme, · line 40

Quoted 10 lines
scripts/qapi/pylintrc +4 -6
-           ex,
-           Run,
-           _,
-           fp,  # fp = open(...)
-           fd,  # fd = os.open(...)
-           ch,
+# Good variable names regexes, separated by a comma. If names match any regex,
+# they will always be accepted
+
+# Allow just about anything, as per Markus's preference.

Does it still flag PEP-8 violations like all lower case class names?

Looks like it in my tests.

Quoted 1 line

If yes, "just about any length" is more precise.

I'll change the comment if you don't mind:

# Suppress complaints about short names. PEP-8 is cool with them, # and so are we.

With that:

No respin necessary.