Type annotation infrastructure and initial typing for qtbot.py#605
Type annotation infrastructure and initial typing for qtbot.py#605The-Compiler merged 28 commits intopytest-dev:masterfrom
Conversation
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks a lot @herobank110!
Left some comments, please take a look!
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks a lot @herobank110, this looks great!
|
Thanks @herobank110! Leaving it open for a few days to give @The-Compiler a chance to review too. 👍 |
Keen to continue contributing with the typing and other stuff you may have |
The-Compiler
left a comment
There was a problem hiding this comment.
Thank you, I'm pretty excited for this! ✨
I added a couple of comments for things I noticed, mostly they're minor things and shouldn't block anything though. A todo-list for follow-ups if we don't do them as part of this PR:
- Use Type Hinting Generics in Standard Collections (
list,dict,typeovertyping.Listetc.) - Use
from __future__ import annotations- Use PEP 604: New Type Union Operator, i.e.
TheType | Noneinstead ofOptional[TheType] - Use "bare" annotations for forward declarations instead of stringified ones
- Configure ruff to enforce
from __future__ import annotationson every file for consistency
- Use PEP 604: New Type Union Operator, i.e.
- Remove redundant type annotations from Sphinx docstrings (and possibly configure Sphinx to pick up the annotations, not sure what's needed for that nowadays)
| # provide easy access to exceptions to qtbot fixtures | ||
| SignalEmittedError = SignalEmittedError | ||
| TimeoutError = TimeoutError | ||
| ScreenshotError = ScreenshotError | ||
| CallbackCalledTwiceError = CallbackCalledTwiceError |
There was a problem hiding this comment.
Those seem somewhat confusing - I wonder if we should from ... import SignalEmittedError as SignalEmittedError_ or something to make clear what happens here?
There was a problem hiding this comment.
I believe it could introduce breaking changes to remove or alias the imports, eg if users wrote from pytestqt.qtbot import TimeoutError
Another option to reduce confusion in the member variables: eg SignalEmittedError = wait_signal.SignalEmittedError
Thanks both for reviewing. Changed to use the Type Hinting Generics in Standard Collections. Saving the rest for later if its OK :) |
for more information, see https://pre-commit.ci
Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
37194d2 to
5e4dbd5
Compare
|
Looking great, thanks again! |
|
Ugh, meant to squash merge but clicked too fast.... sorry @nicoddemus 😅 |
|
No worries, it happens. 👍 |
Initial version of adding type annotations to the library.
infrastructure of mypy in precommit (ci and local type checking)
Typing focused around qtbot.py to start with
Note: qt objects are typed with aliases refering to Any - this may be upgraded in future to use correct types.
Fixes #417