Closed
Description
See /~https://github.com/python/typeshed/tree/master/stubs/selenium/selenium/webdriver/common
While the following codes are running fine:
"""Show bug."""
from typing import Any, Literal, Type
from selenium import webdriver
from selenium.webdriver import chrome, firefox
from selenium.webdriver.common.options import ArgOptions
from selenium.webdriver.remote.webdriver import WebDriver
def fun(browser: Literal["chrome", "firefox"]) -> Any:
"""Show bug."""
driver_class: Type[WebDriver]
options: ArgOptions
if browser == "chrome":
driver_class = webdriver.Chrome
options = chrome.options.Options()
elif browser == "firefox":
driver_class = webdriver.Firefox
options = firefox.options.Options()
return (driver_class, options)
"""Show bug."""
from selenium.webdriver import chrome
from selenium.webdriver.common.options import ArgOptions
def fun() -> ArgOptions:
"""Show bug."""
return chrome.options.Options()
I see various errors in Pylance and mypy:
Import "selenium.webdriver.common.options" could not be resolved
Incompatible types in assignment (expression has type "Options", variable has type "ArgOptions")
Incompatible return value type (got "Options", expected "ArgOptions") [return-value]
Interstingly, selenium.webdriver.common.options
is not mentioned here, either: https://www.selenium.dev/selenium/docs/api/py/api.html#webdriver-common