Skip to content

Commit cd4699a

Browse files
authored
fix: fix type checker errors for pyright (#1203)
* Add `__all__` to specify public API for `appium.webdriver` In `py.typed` modules, imported symbols considered private[^1], which is not importable by users. To become public interface, explicit `__all__` symbol is required. [^1]: https://typing.python.org/en/latest/spec/distributing.html#library-interface-public-and-private-symbols * Comment out unimplemented methods in CanExecuteScripts protocol * Uncomment and add deprecation warnings for unimplemented methods Added deprecation warnings for unimplemented methods in CanExecuteScripts protocol. * Update deprecation messages in CanExecuteScripts * Restore CanExecuteScripts protocol methods * Import Remote class from the original source * Fix formatting * Adjust formatting * Adjust formatting * Add explicit `__all__` and remove lint exceptions
1 parent 2a14455 commit cd4699a

File tree

10 files changed

+20
-4
lines changed

10 files changed

+20
-4
lines changed

.ruff.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ select = [
1313

1414
[lint.per-file-ignores]
1515
"__init__.py" = [
16-
# unused-import
17-
"F401",
1816
# import violations
1917
"E402"
2018
]

appium/options/android/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
from .espresso.base import EspressoOptions
22
from .uiautomator2.base import UiAutomator2Options
3+
4+
__all__ = ['EspressoOptions', 'UiAutomator2Options']

appium/options/common/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from .base import AppiumOptions
2+
3+
__all__ = ['AppiumOptions']

appium/options/flutter_integration/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
# limitations under the License.
1414

1515
from .base import FlutterOptions
16+
17+
__all__ = ['FlutterOptions']

appium/options/gecko/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from .base import GeckoOptions
2+
3+
__all__ = ['GeckoOptions']

appium/options/ios/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
from .safari.base import SafariOptions
22
from .xcuitest.base import XCUITestOptions
3+
4+
__all__ = ['SafariOptions', 'XCUITestOptions']

appium/options/mac/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from .mac2.base import Mac2Options
2+
3+
__all__ = ['Mac2Options']

appium/options/windows/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from .windows.base import WindowsOptions
2+
3+
__all__ = ['WindowsOptions']

appium/webdriver/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818

1919
from .webdriver import WebDriver as Remote
2020
from .webelement import WebElement
21+
22+
__all__ = ['Remote', 'WebElement']

appium/webdriver/webdriver.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
1616

17-
from selenium import webdriver
1817
from selenium.common.exceptions import (
1918
InvalidArgumentException,
2019
SessionNotCreatedException,
@@ -23,6 +22,9 @@
2322
)
2423
from selenium.webdriver.remote.command import Command as RemoteCommand
2524
from selenium.webdriver.remote.remote_connection import RemoteConnection
25+
26+
# `selenium.webdriver.Remote` could be used instead, but Pyright wouldn't locate the class properly.
27+
from selenium.webdriver.remote.webdriver import WebDriver as Remote
2628
from typing_extensions import Self
2729

2830
from appium.common.logger import logger
@@ -208,7 +210,7 @@ def _get_remote_connection_and_client_config(
208210

209211

210212
class WebDriver(
211-
webdriver.Remote,
213+
Remote,
212214
ActionHelpers,
213215
Activities,
214216
Applications,

0 commit comments

Comments
 (0)