Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ select = [
"FURB", # Refurb
"SIM", # Simplify
"UP", # Upgrade
"RUF", # Ruff-specific rules
]

[lint.per-file-ignores]
Expand Down
4 changes: 2 additions & 2 deletions appium/options/common/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

import copy
from typing import Any, TypeVar
from typing import Any, ClassVar, TypeVar

from selenium.webdriver.common.options import BaseOptions

Expand Down Expand Up @@ -60,7 +60,7 @@ class AppiumOptions(
'webSocketUrl', # WebDriver BiDi
]
)
_OSS_W3C_CONVERSION = {
_OSS_W3C_CONVERSION: ClassVar[dict[str, str]] = {
'acceptSslCerts': 'acceptInsecureCerts',
'version': 'browserVersion',
'platform': PLATFORM_NAME,
Expand Down
2 changes: 1 addition & 1 deletion appium/options/gecko/marionette_port_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def marionette_port(self) -> int | None:
@marionette_port.setter
def marionette_port(self, value: int) -> None:
"""
Selects the port for Geckodrivers connection to the Marionette
Selects the port for Geckodriver's connection to the Marionette
remote protocol. The existing Firefox instance must have Marionette
enabled. To enable the remote protocol in Firefox, you can pass the
-marionette flag. Unless the marionette.port preference has been
Expand Down
2 changes: 1 addition & 1 deletion appium/webdriver/appium_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AppiumConnection(RemoteConnection):
"""

user_agent = f'{PREFIX_HEADER}{library_version()} ({RemoteConnection.user_agent})'
extra_headers = {}
extra_headers = {} # noqa: RUF012

@classmethod
def get_remote_connection_headers(cls, parsed_url: 'ParseResult', keep_alive: bool = True) -> dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions appium/webdriver/appium_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def start(self, **kwargs: Any) -> sp.Popen:
# noinspection PyUnresolvedReferences
err_output = self._process.stderr.read()
if err_output:
error_msg += f'\nOriginal error: {str(err_output)}'
error_msg += f'\nOriginal error: {err_output!s}'
self.stop()
raise AppiumServiceError(error_msg)
return self._process
Expand Down Expand Up @@ -262,7 +262,7 @@ def get_main_script(node: str | None, npm: str | None) -> str:
npm_path = npm or get_npm()
for args in [['root', '-g'], ['root']]:
try:
modules_root = sp.check_output([npm_path] + args).strip().decode('utf-8')
modules_root = sp.check_output([npm_path, *args]).strip().decode('utf-8')
full_path = os.path.join(modules_root, *MAIN_SCRIPT_PATH.split('/'))
if os.path.exists(full_path):
result = full_path
Expand Down
2 changes: 1 addition & 1 deletion appium/webdriver/errorhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}


def format_stacktrace(original: None | str | Sequence) -> list[str]:
def format_stacktrace(original: str | Sequence | None) -> list[str]:
if not original:
return []
if isinstance(original, str):
Expand Down
12 changes: 7 additions & 5 deletions appium/webdriver/extensions/android/nativekey.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import ClassVar


class AndroidKeyMetastate:
"""Keyboard metastate constants for Android key events.
Expand Down Expand Up @@ -1054,7 +1056,7 @@ class AndroidKey:
# Key code constant: Copy key.
COPY = 278

gamepad_buttons = [
gamepad_buttons: ClassVar[list[int]] = [
BUTTON_A,
BUTTON_B,
BUTTON_C,
Expand Down Expand Up @@ -1093,14 +1095,14 @@ def is_gamepad_button(code: int) -> bool:
"""Returns true if the specified nativekey is a gamepad button."""
return code in AndroidKey.gamepad_buttons

confirm_buttons = [DPAD_CENTER, ENTER, SPACE, NUMPAD_ENTER]
confirm_buttons: ClassVar[list[int]] = [DPAD_CENTER, ENTER, SPACE, NUMPAD_ENTER]

@staticmethod
def is_confirm_key(code: int) -> bool:
"""Returns true if the key will, by default, trigger a click on the focused view."""
return code in AndroidKey.confirm_buttons

media_buttons = [
media_buttons: ClassVar[list[int]] = [
MEDIA_PLAY,
MEDIA_PAUSE,
MEDIA_PLAY_PAUSE,
Expand All @@ -1120,7 +1122,7 @@ def is_media_key(code: int) -> bool:
interested in media key events."""
return code in AndroidKey.media_buttons

system_buttons = [
system_buttons: ClassVar[list[int]] = [
MENU,
SOFT_RIGHT,
HOME,
Expand Down Expand Up @@ -1155,7 +1157,7 @@ def is_system_key(code: int) -> bool:
"""Returns true if the key is a system key, System keys can not be used for menu shortcuts."""
return code in AndroidKey.system_buttons

wake_buttons = [BACK, MENU, WAKEUP, PAIRING, STEM_1, STEM_2, STEM_3]
wake_buttons: ClassVar[list[int]] = [BACK, MENU, WAKEUP, PAIRING, STEM_1, STEM_2, STEM_3]

@staticmethod
def is_wake_key(code: int) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_double_click(self):
request_body = get_httpretty_request_body(httpretty.last_request())
arguments = request_body['args'][0]
assert request_body['script'] == 'flutter: doubleClick'
assert list(arguments['origin'].values())[0] == 'element_id'
assert next(iter(arguments['origin'].values())) == 'element_id'
assert arguments['offset'] == {'x': 10, 'y': 20}

@httpretty.activate
Expand All @@ -61,8 +61,8 @@ def test_drag_and_drop(self):
request_body = get_httpretty_request_body(httpretty.last_request())
arguments = request_body['args'][0]
assert request_body['script'] == 'flutter: dragAndDrop'
assert list(arguments['source'].values())[0] == 'element_id1'
assert list(arguments['target'].values())[0] == 'element_id2'
assert next(iter(arguments['source'].values())) == 'element_id1'
assert next(iter(arguments['target'].values())) == 'element_id2'

@httpretty.activate
def test_scroll_till_visible(self):
Expand Down
4 changes: 2 additions & 2 deletions test/unit/webdriver/flutter_integration/flutter_waits_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_wait_for_visible_with_webelement(self):
request_body = get_httpretty_request_body(httpretty.last_request())
arguments = request_body['args'][0]
assert request_body['script'] == 'flutter: waitForVisible'
assert list(arguments['element'].values())[0] == 'element_id'
assert next(iter(arguments['element'].values())) == 'element_id'
assert arguments['timeout'] == 5

@httpretty.activate
Expand Down Expand Up @@ -100,5 +100,5 @@ def test_wait_for_invisible_with_webelement(self):
request_body = get_httpretty_request_body(httpretty.last_request())
arguments = request_body['args'][0]
assert request_body['script'] == 'flutter: waitForAbsent'
assert list(arguments['element'].values())[0] == 'element_id'
assert next(iter(arguments['element'].values())) == 'element_id'
assert arguments['timeout'] == 5
Loading