[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 10/38] qapi/common.py: delint with pylint
From: |
Cleber Rosa |
Subject: |
Re: [PATCH v2 10/38] qapi/common.py: delint with pylint |
Date: |
Wed, 23 Sep 2020 12:01:19 -0400 |
On Tue, Sep 22, 2020 at 05:00:33PM -0400, John Snow wrote:
> At this point, that just means using a consistent strategy for constant names.
> constants get UPPER_CASE and names not used externally get a leading
> underscore.
>
> As a preference, while renaming constants to be UPPERCASE, move them to
> the head of the file. Generally, it's nice to be able to audit the code
> that runs on import in one central place.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> scripts/qapi/common.py | 18 ++++++++----------
> scripts/qapi/schema.py | 14 +++++++-------
> 2 files changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index e0c5871b10..bddfb5a9e5 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -14,6 +14,11 @@
> import re
>
>
> +EATSPACE = '\033EATSPACE.'
> +POINTER_SUFFIX = ' *' + EATSPACE
> +_C_NAME_TRANS = str.maketrans('.-', '__')
IMO _C_NAME_TRANS is solely the concern of the c_name() function, and
should not be a global. If you're concerned with speed (which I don't
think you should) you could still do:
def c_name(name, protect=True,
name_translation=str.maketrans('.-', '__')):
...
name = name.translate(name_translation)
Keeping in mind that you're adding a mutable type to a function
argument *on purpose*. I'd really favor having that statement within
the only function that uses it, though.
- Cleber.
signature.asc
Description: PGP signature
[PATCH v2 29/38] qapi/gen.py: delint with pylint, John Snow, 2020/09/22
[PATCH v2 10/38] qapi/common.py: delint with pylint, John Snow, 2020/09/22
[PATCH v2 27/38] qapi/gen.py: Remove unused parameter, John Snow, 2020/09/22
[PATCH v2 23/38] qapi/source.py: delint with pylint, John Snow, 2020/09/22
[PATCH v2 11/38] qapi/common.py: Replace one-letter 'c' variable, John Snow, 2020/09/22