typing: Add argument type for *args

Phil Thompson phil at riverbankcomputing.com
Fri Jul 14 13:43:37 BST 2023


On 09/07/2023 01:11, Florian Bruhin wrote:
> Hey,
> 
> ...okay, I lied. This is the last one.
> 
> There are some places in PyQt where it takes *args, namely:
> 
>     PyQt6/bindings/QtGui/qpolygon.sip
>     66:    void setPoints(int firstx, int firsty, ...);
>     84:    void putPoints(int index, int firstx, int firsty, ...);
> 
>     PyQt6/bindings/QtGui/qpainter.sip
>     196:    void drawPoints(const QPointF *point, ...);
>     210:    void drawPoints(const QPoint *point, ...);
>     224:    void drawLines(const QLineF *line, ...);
>     242:    void drawLines(const QPointF *pointPair, ...);
>     256:    void drawLines(const QLine *line, ...);
>     274:    void drawLines(const QPoint *pointPair, ...);
>     288:    void drawRects(const QRectF *rect, ...);
>     302:    void drawRects(const QRect *rect, ...);
>     320:    void drawPolyline(const QPointF *point, ...);
>     334:    void drawPolyline(const QPoint *point, ...);
>     350:    void drawPolygon(const QPointF *point, ...);
>     364:    void drawPolygon(const QPoint *point, ...);
>     380:    void drawConvexPolygon(const QPointF *point, ...);
>     394:    void drawConvexPolygon(const QPoint *point, ...);
> 
>     PyQt6/bindings/QtDBus/qdbusabstractinterface.sip
>     98:    QDBusMessage call(const QString &method, ...);
>     112:    QDBusMessage call(QDBus::CallMode mode, const QString 
> &method, ...);
>     176:    QDBusPendingCall asyncCall(const QString &method, ...);
> 
> 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'?

Phil


More information about the PyQt mailing list