bug-gnulib
[Top][All Lists]
Advanced

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

gnulib-tool.py: Fix pylint 'raise-missing-from' warnings.


From: Collin Funk
Subject: gnulib-tool.py: Fix pylint 'raise-missing-from' warnings.
Date: Thu, 4 Apr 2024 15:38:53 -0700
User-agent: Mozilla Thunderbird

Hi Bruno,

On 4/4/24 5:48 AM, Bruno Haible wrote:
> The only difference between the two outputs is the message between the two
> stack traces. The latter sounds like a program bug; therefore I would say,
> let's use the chaining — just in order to clarify that the second exception
> is intended.

Ah, that makes sense. I didn't really think about the intent that the
warning might convey. I agree with your assessment.

The first patch attached fixes all of those warnings by adding the
explicit chaining.

> Oh, indeed there's a fallacy here: {} denotes a dict, not a set!
> 
>>>> type({'x','y'})
> <class 'set'>
>>>> type({'x'})
> <class 'set'>
>>>> type({})
> <class 'dict'>

Yes, it seems the Python developers ran out of brackets to use and
decided that sets should be the odd ones out. :(

>>> type(())
> <class 'tuple'>
>>> type([])
> <class 'list'>
>>> type({})
> <class 'dict'>
>>> type(set())
> <class 'set'>

The second patch disables that warning and changes the one occurrence
of '{}' we have to 'dict()'.

> This is surprising enough that we should add to our coding style:
> 
>   - Never use the {} literal, because it denotes a dictionary,
>     as opposed to {x}, {x,y}, etc., which denote sets.

I've also added this to comment to main.py.

Collin

Attachment: 0001-gnulib-tool.py-Fix-pylint-raise-missing-from-warning.patch
Description: Text Data

Attachment: 0002-gnulib-tool.py-Ignore-use-dict-literal-warnings.patch
Description: Text Data


reply via email to

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