diff mbox series

[24/26] qapi/parser.py: remove one and two-letter variables

Message ID 20200922223525.4085762-25-jsnow@redhat.com
State New
Headers show
Series qapi: static typing conversion, pt5 | expand

Commit Message

John Snow Sept. 22, 2020, 10:35 p.m. UTC
Standard pylint complaint: use more descriptibe variable names. OK,
fine.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/parser.py | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index cdb64ffc22..818f8bc580 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -57,8 +57,8 @@  class QAPIParseError(QAPISourceError):
     @classmethod
     def make(cls: Type[T], parser: 'QAPISchemaParser', msg: str) -> T:
         col = 1
-        for ch in parser.src[parser.line_pos:parser.pos]:
-            if ch == '\t':
+        for char in parser.src[parser.line_pos:parser.pos]:
+            if char == '\t':
                 col = (col + 7) % 8 + 1
             else:
                 col += 1
@@ -100,14 +100,16 @@  def __init__(self, fname: str,
         try:
             with open(self._fname, 'r', encoding='utf-8') as fp:
                 self.src = fp.read()
-        except IOError as e:
+        except IOError as err:
             msg = "can't read {kind:s} file '{fname:s}': {errmsg:s}".format(
                 kind='include' if parent else 'schema',
                 fname=self._fname,
-                errmsg=e.strerror
+                errmsg=err.strerror
             )
             context = parent_info if parent_info else self.info
-            raise QAPIParseError(context, msg) from e
+            raise QAPIParseError(context, msg) from err
+
+        # Showtime!
         self._parse()
 
     def _parse(self) -> None:
@@ -245,25 +247,25 @@  def accept(self, skip_comment: bool = True) -> None:
                 string = ''
                 esc = False
                 while True:
-                    ch = self.src[self.cursor]
+                    char = self.src[self.cursor]
                     self.cursor += 1
-                    if ch == '\n':
+                    if char == '\n':
                         raise self._parse_error("missing terminating \"'\"")
                     if esc:
                         # Note: we recognize only \\ because we have
                         # no use for funny characters in strings
-                        if ch != '\\':
-                            raise self._parse_error(f"unknown escape \\{ch}")
+                        if char != '\\':
+                            raise self._parse_error(f"unknown escape \\{char}")
                         esc = False
-                    elif ch == '\\':
+                    elif char == '\\':
                         esc = True
                         continue
-                    elif ch == "'":
+                    elif char == "'":
                         self.val = string
                         return
-                    if ord(ch) < 32 or ord(ch) >= 127:
+                    if ord(char) < 32 or ord(char) >= 127:
                         raise self._parse_error("funny character in string")
-                    string += ch
+                    string += char
             elif self.src.startswith('true', self.pos):
                 self.val = True
                 self.cursor += 3