Skip to content

Overloads from PySide2 don't seem to work correctly #7536

@rggjan

Description

@rggjan

I have this code in test.py:

1 from PySide2.QtCore import QRect
2 from PySide2.QtGui import QPixmap
3 
4 a = QPixmap()
5 
6 reveal_type(a.depth())
7 reveal_type(a.copy(rect=QRect()))
8 reveal_type(a.copy(1, 2, 3, 4))
9 reveal_type(a.copy())

Running mypy test.py produces:

test.py:6: note: Revealed type is 'builtins.int'
test.py:7: note: Revealed type is 'Any'
test.py:8: note: Revealed type is 'Any'
test.py:9: note: Revealed type is 'Any'

So the stubs are found and the non overloaded function on line 6 is evaluated correctly to int.

However, from the overload signature in PySide2/QtGui.pyi:

6188 class QPixmap(PySide2.QtGui.QPaintDevice):
...
6210     @typing.overload
6211     def copy(self, rect:PySide2.QtCore.QRect=...) -> PySide2.QtGui.QPixmap: ...
6212     @typing.overload
6213     def copy(self, x:int, y:int, width:int, height:int) -> PySide2.QtGui.QPixmap: ...
...
6218     def depth(self) -> int: ...

I would expect lines 7 to 9 to evaluate to QPixmap instead of Any...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions