diff --git a/py/BUILD.bazel b/py/BUILD.bazel index 0a4d5228d518d..4774b00a8f005 100644 --- a/py/BUILD.bazel +++ b/py/BUILD.bazel @@ -233,6 +233,7 @@ py_library( "selenium/__init__.py", "selenium/webdriver/__init__.py", ] + glob(["selenium/common/**/*.py"]), + data = ["selenium/webdriver/__init__.pyi"], imports = ["."], visibility = ["//visibility:public"], ) @@ -277,9 +278,7 @@ py_library( name = "common", srcs = glob( ["selenium/webdriver/common/**/*.py"], - exclude = [ - "selenium/webdriver/common/bidi/**", - ], + exclude = ["selenium/webdriver/common/bidi/**"], ), data = [ ":manager-linux", @@ -325,6 +324,7 @@ py_library( py_library( name = "chrome", srcs = glob(["selenium/webdriver/chrome/**/*.py"]), + data = ["selenium/webdriver/chrome/__init__.pyi"], imports = ["."], visibility = ["//visibility:public"], deps = [":chromium"], @@ -334,6 +334,7 @@ py_library( py_library( name = "edge", srcs = glob(["selenium/webdriver/edge/**/*.py"]), + data = ["selenium/webdriver/edge/__init__.pyi"], imports = ["."], visibility = ["//visibility:public"], deps = [":chromium"], @@ -343,7 +344,10 @@ py_library( py_library( name = "firefox", srcs = glob(["selenium/webdriver/firefox/**/*.py"]), - data = [":firefox-driver-prefs"], + data = [ + "selenium/webdriver/firefox/__init__.pyi", + ":firefox-driver-prefs", + ], imports = ["."], visibility = ["//visibility:public"], deps = [ @@ -356,6 +360,7 @@ py_library( py_library( name = "safari", srcs = glob(["selenium/webdriver/safari/**/*.py"]), + data = ["selenium/webdriver/safari/__init__.pyi"], imports = ["."], visibility = ["//visibility:public"], deps = [ @@ -368,6 +373,7 @@ py_library( py_library( name = "ie", srcs = glob(["selenium/webdriver/ie/**/*.py"]), + data = ["selenium/webdriver/ie/__init__.pyi"], imports = ["."], visibility = ["//visibility:public"], deps = [ @@ -380,6 +386,7 @@ py_library( py_library( name = "webkitgtk", srcs = glob(["selenium/webdriver/webkitgtk/**/*.py"]), + data = ["selenium/webdriver/webkitgtk/__init__.pyi"], imports = ["."], visibility = ["//visibility:public"], deps = [ @@ -392,6 +399,7 @@ py_library( py_library( name = "wpewebkit", srcs = glob(["selenium/webdriver/wpewebkit/**/*.py"]), + data = ["selenium/webdriver/wpewebkit/__init__.pyi"], imports = ["."], visibility = ["//visibility:public"], deps = [ diff --git a/py/pyproject.toml b/py/pyproject.toml index 8be36470023e9..840869b1d4286 100644 --- a/py/pyproject.toml +++ b/py/pyproject.toml @@ -67,6 +67,7 @@ binding = "Exec" [tool.setuptools.package-data] "*" = [ "*.py", + "*.pyi", "*.rst", "*.json", "*.xpi", diff --git a/py/selenium/webdriver/__init__.pyi b/py/selenium/webdriver/__init__.pyi new file mode 100644 index 0000000000000..c03fcc67ac1ba --- /dev/null +++ b/py/selenium/webdriver/__init__.pyi @@ -0,0 +1,131 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Type stub with lazy import mapping from __init__.py. + +This stub file is necessary for type checkers and IDEs to automatically have +visibility into lazy modules since they are not imported immediately at runtime. +""" + +# ruff: noqa: I001 + +# Expose runtime version +__version__: str + +# Chrome +from selenium.webdriver.chrome.webdriver import WebDriver as Chrome +from selenium.webdriver.chrome.options import Options as ChromeOptions +from selenium.webdriver.chrome.service import Service as ChromeService + +# Edge +from selenium.webdriver.edge.webdriver import WebDriver as Edge +from selenium.webdriver.edge.webdriver import WebDriver as ChromiumEdge +from selenium.webdriver.edge.options import Options as EdgeOptions +from selenium.webdriver.edge.service import Service as EdgeService + +# Firefox +from selenium.webdriver.firefox.webdriver import WebDriver as Firefox +from selenium.webdriver.firefox.options import Options as FirefoxOptions +from selenium.webdriver.firefox.service import Service as FirefoxService +from selenium.webdriver.firefox.firefox_profile import FirefoxProfile + +# IE +from selenium.webdriver.ie.webdriver import WebDriver as Ie +from selenium.webdriver.ie.options import Options as IeOptions +from selenium.webdriver.ie.service import Service as IeService + +# Safari +from selenium.webdriver.safari.webdriver import WebDriver as Safari +from selenium.webdriver.safari.options import Options as SafariOptions +from selenium.webdriver.safari.service import Service as SafariService + +# Remote +from selenium.webdriver.remote.webdriver import WebDriver as Remote + +# WebKitGTK +from selenium.webdriver.webkitgtk.webdriver import WebDriver as WebKitGTK +from selenium.webdriver.webkitgtk.options import Options as WebKitGTKOptions +from selenium.webdriver.webkitgtk.service import Service as WebKitGTKService + +# WPEWebKit +from selenium.webdriver.wpewebkit.webdriver import WebDriver as WPEWebKit +from selenium.webdriver.wpewebkit.options import Options as WPEWebKitOptions +from selenium.webdriver.wpewebkit.service import Service as WPEWebKitService + +# Common utilities +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.common.proxy import Proxy + +# Submodules +from . import chrome +from . import chromium +from . import common +from . import edge +from . import firefox +from . import ie +from . import remote +from . import safari +from . import support +from . import webkitgtk +from . import wpewebkit + +# Exposed names +__all__ = [ + # Classes + "ActionChains", + "Chrome", + "ChromeOptions", + "ChromeService", + "ChromiumEdge", + "DesiredCapabilities", + "Edge", + "EdgeOptions", + "EdgeService", + "Firefox", + "FirefoxOptions", + "FirefoxProfile", + "FirefoxService", + "Ie", + "IeOptions", + "IeService", + "Keys", + "Proxy", + "Remote", + "Safari", + "SafariOptions", + "SafariService", + "WPEWebKit", + "WPEWebKitOptions", + "WPEWebKitService", + "WebKitGTK", + "WebKitGTKOptions", + "WebKitGTKService", + # Submodules + "chrome", + "chromium", + "common", + "edge", + "firefox", + "ie", + "remote", + "safari", + "support", + "webkitgtk", + "wpewebkit", +] diff --git a/py/selenium/webdriver/chrome/__init__.pyi b/py/selenium/webdriver/chrome/__init__.pyi new file mode 100644 index 0000000000000..44d8a67ea67e2 --- /dev/null +++ b/py/selenium/webdriver/chrome/__init__.pyi @@ -0,0 +1,26 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Type stub with lazy import mapping from __init__.py. + +This stub file is necessary for type checkers and IDEs to automatically have +visibility into lazy modules since they are not imported immediately at runtime. +""" + +from . import options, remote_connection, service, webdriver + +__all__ = ["options", "remote_connection", "service", "webdriver"] diff --git a/py/selenium/webdriver/chrome/remote_connection.py b/py/selenium/webdriver/chrome/remote_connection.py index 134a13d06180e..93c684abf8f86 100644 --- a/py/selenium/webdriver/chrome/remote_connection.py +++ b/py/selenium/webdriver/chrome/remote_connection.py @@ -16,8 +16,8 @@ # under the License. -from selenium.webdriver import DesiredCapabilities from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.remote.client_config import ClientConfig diff --git a/py/selenium/webdriver/edge/__init__.pyi b/py/selenium/webdriver/edge/__init__.pyi new file mode 100644 index 0000000000000..44d8a67ea67e2 --- /dev/null +++ b/py/selenium/webdriver/edge/__init__.pyi @@ -0,0 +1,26 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Type stub with lazy import mapping from __init__.py. + +This stub file is necessary for type checkers and IDEs to automatically have +visibility into lazy modules since they are not imported immediately at runtime. +""" + +from . import options, remote_connection, service, webdriver + +__all__ = ["options", "remote_connection", "service", "webdriver"] diff --git a/py/selenium/webdriver/edge/remote_connection.py b/py/selenium/webdriver/edge/remote_connection.py index 5aa4f99cd304f..dc859e145665b 100644 --- a/py/selenium/webdriver/edge/remote_connection.py +++ b/py/selenium/webdriver/edge/remote_connection.py @@ -16,8 +16,8 @@ # under the License. -from selenium.webdriver import DesiredCapabilities from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.remote.client_config import ClientConfig diff --git a/py/selenium/webdriver/firefox/__init__.pyi b/py/selenium/webdriver/firefox/__init__.pyi new file mode 100644 index 0000000000000..e025d5fc409d1 --- /dev/null +++ b/py/selenium/webdriver/firefox/__init__.pyi @@ -0,0 +1,26 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Type stub with lazy import mapping from __init__.py. + +This stub file is necessary for type checkers and IDEs to automatically have +visibility into lazy modules since they are not imported immediately at runtime. +""" + +from . import firefox_profile, options, remote_connection, service, webdriver + +__all__ = ["firefox_profile", "options", "remote_connection", "service", "webdriver"] diff --git a/py/selenium/webdriver/ie/__init__.pyi b/py/selenium/webdriver/ie/__init__.pyi new file mode 100644 index 0000000000000..b3479da1ad72e --- /dev/null +++ b/py/selenium/webdriver/ie/__init__.pyi @@ -0,0 +1,26 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Type stub with lazy import mapping from __init__.py. + +This stub file is necessary for type checkers and IDEs to automatically have +visibility into lazy modules since they are not imported immediately at runtime. +""" + +from . import options, service, webdriver + +__all__ = ["options", "service", "webdriver"] diff --git a/py/selenium/webdriver/safari/__init__.pyi b/py/selenium/webdriver/safari/__init__.pyi new file mode 100644 index 0000000000000..519f3700f14a0 --- /dev/null +++ b/py/selenium/webdriver/safari/__init__.pyi @@ -0,0 +1,26 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Type stub with lazy import mapping from __init__.py. + +This stub file is necessary for type checkers and IDEs to automatically have +visibility into lazy modules since they are not imported immediately at runtime. +""" + +from . import options, permissions, remote_connection, service, webdriver + +__all__ = ["options", "permissions", "remote_connection", "service", "webdriver"] diff --git a/py/selenium/webdriver/webkitgtk/__init__.pyi b/py/selenium/webdriver/webkitgtk/__init__.pyi new file mode 100644 index 0000000000000..b3479da1ad72e --- /dev/null +++ b/py/selenium/webdriver/webkitgtk/__init__.pyi @@ -0,0 +1,26 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Type stub with lazy import mapping from __init__.py. + +This stub file is necessary for type checkers and IDEs to automatically have +visibility into lazy modules since they are not imported immediately at runtime. +""" + +from . import options, service, webdriver + +__all__ = ["options", "service", "webdriver"] diff --git a/py/selenium/webdriver/wpewebkit/__init__.pyi b/py/selenium/webdriver/wpewebkit/__init__.pyi new file mode 100644 index 0000000000000..b3479da1ad72e --- /dev/null +++ b/py/selenium/webdriver/wpewebkit/__init__.pyi @@ -0,0 +1,26 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Type stub with lazy import mapping from __init__.py. + +This stub file is necessary for type checkers and IDEs to automatically have +visibility into lazy modules since they are not imported immediately at runtime. +""" + +from . import options, service, webdriver + +__all__ = ["options", "service", "webdriver"]