Reconciling pyqtProperty and mypy

Ben Green at
Tue Aug 18 19:54:14 BST 2020


I'm using pyqtProperty a lot, and mypy doesn't seem to play nicely with it.
When defining the setter, it gives a "name already defined" error. Also,
since the type is "Callable[..., Any]", instead of the actual type of the
property, references to that property can give errors.

For example:

class Foo(QObject):
    def series(self) -> QAbstractSeries:
        return self._series

    @series.setter  # mypy error here: Name 'series' already defined on
line x
    def series(self, val):
        self._series = val

    def do_something(self):
        self.series.replace([])  # mypy error here: "Callable[..., Any]"
has no attribute "replace"

Is there any way to reconcile these so I don't have to put in "type:
ignore" comments all over the place?

Ben Green  |  Software Engineer I

*GeckoRobotics* |

*o:* 412.407.2444  *m:* 484.895.5793
*e:* at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the PyQt mailing list