(WIP) Update the parameter type annotations for pyqtSignal.__init__#107
(WIP) Update the parameter type annotations for pyqtSignal.__init__#107BryceBeagle wants to merge 1 commit intopython-qt-tools:masterfrom
Conversation
The *types annotation is currently broken. Feedback appreciated
| def disconnect(self, slot: typing.Union["PYQT_SLOT", "QMetaObject.Connection"]) -> None: ... | ||
|
|
||
|
|
||
| _SignalTypesT = typing.TypeVar("_SignalTypesT", type, typing.List[type]) |
There was a problem hiding this comment.
| _SignalTypesT = typing.TypeVar("_SignalTypesT", type, typing.List[type]) | |
| _SignalTypesT = typing.TypeVar("_SignalTypesT", typing.Union[type, typing.List[type]]) |
I can't say I know the reasons for why this works and the separate types don't but... it does. :| Is there something that makes it wrong despite passing?
There was a problem hiding this comment.
Err, hold that thought... maybe I didn't test properly here...
There was a problem hiding this comment.
Ok, trying again and hoping to be less silly. As is, there is no relationship being created between multiple hints so this can just be an alias instead, I think?
| _SignalTypesT = typing.TypeVar("_SignalTypesT", type, typing.List[type]) | |
| _SignalTypesT = typing.Union[type, typing.List[type]] |
(except with a different variable name changed here and at the use sites)
There was a problem hiding this comment.
The issue here is that I need to keep all of the var args of the same type. Using the Union allows for
a = pyqtSignal([int, bool], float)but this is not allowed by PyQt. You can use only types OR only lists of types
There was a problem hiding this comment.
Well, I think my second attempt was less silly... though still not helpful. Humm.
Resolves #105
The *types annotation is currently broken. Feedback appreciated
Minimal reprduction of issue:
https://mypy-play.net/?mypy=latest&python=3.8&gist=57db3e86d7202dc8ebe4f24965409a3f
Edit: Opened an issue on the mypy issue tracker: python/mypy#9569