Skip to content

Commit d9c8a5c

Browse files
committed
save
1 parent 9a8a4b5 commit d9c8a5c

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/pytestqt/qtbot.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import contextlib
22
import weakref
33
import warnings
4-
from typing import TYPE_CHECKING, Callable, Optional, Any
4+
from typing import TYPE_CHECKING, Callable, Optional, Any, cast
55

66
from pytestqt.exceptions import TimeoutError, ScreenshotError
77
from pytestqt.qt_compat import qt_api
@@ -19,14 +19,14 @@
1919
# versions possibly using 'qtpy' library.
2020
QWidget = Any
2121

22-
BeforeCloseFunc = Callable[[QWidget], None]
22+
BeforeCloseFunc = Callable[["QWidget"], None]
2323

2424

25-
def _parse_ini_boolean(value):
25+
def _parse_ini_boolean(value: bool | str) -> bool:
2626
if value in (True, False):
27-
return value
27+
return cast("bool", value)
2828
try:
29-
return {"true": True, "false": False}[value.lower()]
29+
return {"true": True, "false": False}[cast("str", value).lower()]
3030
except KeyError:
3131
raise ValueError("unknown string for bool: %r" % value)
3232

@@ -178,9 +178,7 @@ def _should_raise(self, raising_arg):
178178
else:
179179
return True
180180

181-
def addWidget(
182-
self, widget: "QWidget", *, before_close_func: Optional[BeforeCloseFunc] = None
183-
):
181+
def addWidget(self, widget, *, before_close_func: Optional[BeforeCloseFunc] = None):
184182
"""
185183
Adds a widget to be tracked by this bot. This is not required, but will ensure that the
186184
widget gets closed by the end of the test, so it is highly recommended.
@@ -198,7 +196,7 @@ def addWidget(
198196
raise TypeError(f"Need to pass a QWidget to addWidget: {widget!r}")
199197
_add_widget(self._request.node, widget, before_close_func=before_close_func)
200198

201-
def waitActive(self, widget, *, timeout=5000):
199+
def waitActive(self, widget, *, timeout: int = 5000):
202200
"""
203201
Context manager that waits for ``timeout`` milliseconds or until the window is active.
204202
If window is not exposed within ``timeout`` milliseconds, raise
@@ -743,7 +741,7 @@ def mouseRelease(*args, **kwargs):
743741

744742
def _add_widget(
745743
item,
746-
widget: "QWidget",
744+
widget,
747745
*,
748746
before_close_func: Optional[BeforeCloseFunc] = None,
749747
):

0 commit comments

Comments
 (0)