From 81a1b79226a432bd28fefe0587ce2cc9260f2e3a Mon Sep 17 00:00:00 2001 From: sebthom Date: Wed, 16 Feb 2022 20:11:26 +0100 Subject: [PATCH] use TypeVar with in declaration of SeleniumMixin.web_await() --- kleinanzeigen_bot/selenium_mixin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kleinanzeigen_bot/selenium_mixin.py b/kleinanzeigen_bot/selenium_mixin.py index 498e8fb..359783c 100644 --- a/kleinanzeigen_bot/selenium_mixin.py +++ b/kleinanzeigen_bot/selenium_mixin.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later """ import logging, os, shutil, sys from collections.abc import Callable, Iterable -from typing import Any, Final +from typing import Any, Final, TypeVar from selenium import webdriver 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") +T:Final[TypeVar] = TypeVar('T') + class SeleniumMixin: @@ -155,7 +157,7 @@ class SeleniumMixin: 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 :raises NoSuchElementException: if element could not be found within time