bug-gnulib
[Top][All Lists]
Advanced

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

gnulib-tool.py: Ignore pylint 'unidiomatic-typecheck' warnings.


From: Collin Funk
Subject: gnulib-tool.py: Ignore pylint 'unidiomatic-typecheck' warnings.
Date: Wed, 3 Apr 2024 03:22:36 -0700
User-agent: Mozilla Thunderbird

I'm trying to fix some easy things to make warnings more meaningful.
Here is two patches for that.

The first adds an option to the pylintrc configuration file. Right now
the pylint output gets spammed with 'unidiomatic-typecheck' warnings.
This is because we use:

     if type(var) is str:

instead of:

    if isinstance(var, str):

I think we discussed this previously and concluded it wasn't
important. The warning spam is more likely to cause problems than the
difference between these two conditions, in my opinion.

The second just removes the explicit inheritance from 'object' from
our class declarations. Pylint warns about this, but it also feels
like more "standard" Python 3 to me. The implicit object inheritance
was added over 20 years ago, so I don't see any issues with it [1].

Not that this is likely to cause any issues, but since it is Python
you can do interesting things like this:

    #!/usr/bin/env python3
    object = str
    class MyClass(object):
        def __init__(self) -> None:
            pass
    # Prints "(<class 'str'>,)".
    print(MyClass.__bases__)

[1] https://docs.python.org/3/whatsnew/2.2.html

Collin

Attachment: 0001-gnulib-tool.py-Ignore-pylint-unidiomatic-typecheck-w.patch
Description: Text Data

Attachment: 0002-gnulib-tool.py-Modernize-class-declarations-to-Pytho.patch
Description: Text Data


reply via email to

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