qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Cleber Rosa <crosa@redhat.com>, John Snow <jsnow@redhat.com>,
	qemu-devel@nongnu.org, Eduardo Habkost <ehabkost@redhat.com>,
	Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [PATCH 24/26] qapi/parser.py: remove one and two-letter variables
Date: Tue, 22 Sep 2020 18:35:23 -0400	[thread overview]
Message-ID: <20200922223525.4085762-25-jsnow@redhat.com> (raw)
In-Reply-To: <20200922223525.4085762-1-jsnow@redhat.com>

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 --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
-- 
2.26.2



  parent reply	other threads:[~2020-09-22 22:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 22:34 [PATCH 00/26] qapi: static typing conversion, pt5 John Snow
2020-09-22 22:35 ` [PATCH 01/26] qapi/parser.py: refactor parsing routine into method John Snow
2020-09-22 22:35 ` [PATCH 02/26] qapi/parser.py: group variable declarations in __init__ John Snow
2020-09-22 22:35 ` [PATCH 03/26] qapi/parser.py: use 'with' statement for opening files John Snow
2020-09-22 22:35 ` [PATCH 04/26] qapi/source.py: Add default arguments to QAPISourceInfo John Snow
2020-09-22 22:35 ` [PATCH 05/26] qapi/parser.py: start source info at line 0 John Snow
2020-09-22 22:35 ` [PATCH 06/26] qapi/parser.py: raise QAPIParseError during file opening John Snow
2020-09-22 22:35 ` [PATCH 07/26] qapi/parser.py: fully remove 'null' constant John Snow
2020-09-22 22:35 ` [PATCH 08/26] qapi/parser.py: Assert lexer value is a string John Snow
2020-09-22 22:35 ` [PATCH 09/26] qapi/parser.py: assert get_expr returns object in outer loop John Snow
2020-09-22 22:35 ` [PATCH 10/26] qapi/parser.py: assert object keys are strings John Snow
2020-09-22 22:35 ` [PATCH 11/26] qapi/parser.py: Convert several methods to @classmethod John Snow
2020-09-22 22:35 ` [PATCH 12/26] qapi/parser.py: add casts to pragma checks John Snow
2020-09-22 22:35 ` [PATCH 13/26] qapi/parser.py: add type hint annotations John Snow
2020-09-22 22:35 ` [PATCH 14/26] qapi/parser.py: add docstrings John Snow
2020-09-22 22:35 ` [PATCH 15/26] qapi/parser.py: add ParsedExpression type John Snow
2020-09-22 22:35 ` [PATCH 16/26] qapi/pragma.py: Move QAPISchemaPragma into its own module John Snow
2020-09-22 22:35 ` [PATCH 17/26] qapi/pragma.py: Move pragma parsing out of parser.py John Snow
2020-09-22 22:35 ` [PATCH 18/26] qapi/parser.py: Modify _include() to use parser state John Snow
2020-09-22 22:35 ` [PATCH 19/26] qapi/parser.py: add parent argument John Snow
2020-09-22 22:35 ` [PATCH 20/26] qapi/parser.py: remove unused check_args_section arguments John Snow
2020-09-22 22:35 ` [PATCH 21/26] qapi/parser.py: QAPIDoc: convert @staticmethod to @classmethod John Snow
2020-09-22 22:35 ` [PATCH 22/26] qapi/parser.py: add type hint annotations (QAPIDoc) John Snow
2020-09-22 22:35 ` [PATCH 23/26] qapi/parser.py: enable mypy checks John Snow
2020-09-22 22:35 ` John Snow [this message]
2020-09-22 22:35 ` [PATCH 25/26] qapi/parser.py: Silence too-few-public-methods warning John Snow
2020-09-22 22:35 ` [PATCH 26/26] qapi/parser.py: enable pylint checks John Snow
2020-09-22 22:54 ` [PATCH 00/26] qapi: static typing conversion, pt5 John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200922223525.4085762-25-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).