[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: typing: Add argument type for *args
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2023-07-15 20:55:27
Message-ID: f36fecd3bc6623f0bf250d3931aaf6aa () riverbankcomputing ! com
[Download RAW message or body]

On 14/07/2023 16:30, Florian Bruhin wrote:
>> On 09/07/2023 01:11, Florian Bruhin wrote:
>> > There are some places in PyQt where it takes *args, namely:
>> >
>> >     [...]
>> >
>> > Unfortunately, this results in "*a1" or "*a2" in the .pyi, without any
>> > type information.
>> >
>> > From what I can see in PyQt6-stubs, those should be:
>> >
>> > - int for QPolygon
>> > - The same type as the first argument for QPainter
>> > - Any for QDBusAbstractInterface
>> >   (an explicit "Any" would be preferrable to no annotation)
>> 
>> Don't those imply a single argument? How do you express 'any number of
>> int arguments'?
> 
> `*args: int` is defined as "any number of int arguments", see e.g. the
> last example here:
> https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#functions
> 
> Or in the original typing pep:
> https://peps.python.org/pep-0484/#arbitrary-argument-lists-and-default-argument-values
> 
> What's not possible AFAIK is to annotate a *args where the types differ
> between elements. For **kwargs, it recently became possible with
> TypedDict and typing.Unpack: https://peps.python.org/pep-0692/

Fixed.

Thanks,
Phil
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic