mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
use TypeVar with in declaration of SeleniumMixin.web_await()
This commit is contained in:
@@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
|||||||
"""
|
"""
|
||||||
import logging, os, shutil, sys
|
import logging, os, shutil, sys
|
||||||
from collections.abc import Callable, Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from typing import Any, Final
|
from typing import Any, Final, TypeVar
|
||||||
|
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.common.exceptions import NoSuchElementException, TimeoutException
|
from selenium.common.exceptions import NoSuchElementException, TimeoutException
|
||||||
@@ -26,6 +26,8 @@ from .utils import ensure, pause
|
|||||||
|
|
||||||
LOG:Final[logging.Logger] = logging.getLogger("kleinanzeigen_bot.selenium_mixin")
|
LOG:Final[logging.Logger] = logging.getLogger("kleinanzeigen_bot.selenium_mixin")
|
||||||
|
|
||||||
|
T:Final[TypeVar] = TypeVar('T')
|
||||||
|
|
||||||
|
|
||||||
class SeleniumMixin:
|
class SeleniumMixin:
|
||||||
|
|
||||||
@@ -155,7 +157,7 @@ class SeleniumMixin:
|
|||||||
|
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
def web_await(self, condition: Callable[[WebDriver], WebElement], timeout:int = 5) -> WebElement:
|
def web_await(self, condition: Callable[[WebDriver], T], timeout:int = 5) -> T:
|
||||||
"""
|
"""
|
||||||
:param timeout: timeout in seconds
|
:param timeout: timeout in seconds
|
||||||
:raises NoSuchElementException: if element could not be found within time
|
:raises NoSuchElementException: if element could not be found within time
|
||||||
|
|||||||
Reference in New Issue
Block a user