Skip to content

Commit b142e00

Browse files
authored
ci: add pylint_quotes for pylint to use single quote as primary method (#886)
1 parent fb8415e commit b142e00

22 files changed

+41
-36
lines changed

.pylintrc

+4
Original file line numberDiff line numberDiff line change
@@ -551,3 +551,7 @@ known-third-party=enchant
551551
# Exceptions that will emit a warning when being caught. Defaults to
552552
# "Exception"
553553
overgeneral-exceptions=Exception
554+
555+
string-quote=single
556+
triple-quote=single
557+
docstring-quote=double

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ black: ## Run black
1616
.PHONY: pylint
1717
pylint: ## Run pylint
1818
# TODO Remove --disable=E1136 when no errors in py39
19-
python -m pylint $(ARGS) --rcfile .pylintrc appium test --disable=E1136
19+
python -m pylint $(ARGS) --load-plugins pylint_quotes --rcfile .pylintrc appium test --disable=E1136
2020

2121
.PHONY: mypy
2222
mypy: ## Run mypy

Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mypy = "<2.0"
1111
mock = "~=5.0"
1212
pre-commit = "~=2.21"
1313
pylint = "~=2.17.3"
14+
pylint-quotes = "~=0.2.3"
1415
pytest = "~=7.4"
1516
pytest-cov = "~=4.1"
1617
python-dateutil = "~=2.8"

appium/webdriver/common/multi_action.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MultiAction:
3838

3939
def __init__(self, driver: 'WebDriver', element: Optional['WebElement'] = None) -> None:
4040
warnings.warn(
41-
"[Deprecated] 'MultiAction' action is deprecated. Please use W3C actions instead.", DeprecationWarning
41+
'[Deprecated] \'MultiAction\' action is deprecated. Please use W3C actions instead.', DeprecationWarning
4242
)
4343

4444
self._driver = driver

appium/webdriver/common/touch_action.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TouchAction:
4242

4343
def __init__(self, driver: Optional['WebDriver'] = None):
4444
warnings.warn(
45-
"[Deprecated] 'TouchAction' action is deprecated. Please use W3C actions instead.", DeprecationWarning
45+
'[Deprecated] \'TouchAction\' action is deprecated. Please use W3C actions instead.', DeprecationWarning
4646
)
4747

4848
self._driver = driver

appium/webdriver/extensions/action_helpers.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def scroll(self, origin_el: WebElement, destination_el: WebElement, duration: Op
4646
if duration is None:
4747
duration = 600
4848

49-
touch_input = PointerInput(interaction.POINTER_TOUCH, "touch")
49+
touch_input = PointerInput(interaction.POINTER_TOUCH, 'touch')
5050

5151
actions = ActionChains(self)
5252
actions.w3c_actions = ActionBuilder(self, mouse=touch_input)
@@ -96,7 +96,7 @@ def tap(self, positions: List[Tuple[int, int]], duration: Optional[int] = None)
9696
"""
9797
if len(positions) == 1:
9898
actions = ActionChains(self)
99-
actions.w3c_actions = ActionBuilder(self, mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))
99+
actions.w3c_actions = ActionBuilder(self, mouse=PointerInput(interaction.POINTER_TOUCH, 'touc'))
100100
x = positions[0][0]
101101
y = positions[0][1]
102102
actions.w3c_actions.pointer_action.move_to_location(x, y)
@@ -145,7 +145,7 @@ def swipe(self, start_x: int, start_y: int, end_x: int, end_y: int, duration: in
145145
Returns:
146146
Union['WebDriver', 'ActionHelpers']: Self instance
147147
"""
148-
touch_input = PointerInput(interaction.POINTER_TOUCH, "touch")
148+
touch_input = PointerInput(interaction.POINTER_TOUCH, 'touch')
149149

150150
actions = ActionChains(self)
151151
actions.w3c_actions = ActionBuilder(self, mouse=touch_input)
@@ -174,7 +174,7 @@ def flick(self, start_x: int, start_y: int, end_x: int, end_y: int) -> 'WebDrive
174174
Union['WebDriver', 'ActionHelpers']: Self instance
175175
"""
176176
actions = ActionChains(self)
177-
actions.w3c_actions = ActionBuilder(self, mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))
177+
actions.w3c_actions = ActionBuilder(self, mouse=PointerInput(interaction.POINTER_TOUCH, 'touch'))
178178
actions.w3c_actions.pointer_action.move_to_location(start_x, start_y)
179179
actions.w3c_actions.pointer_action.pointer_down()
180180
actions.w3c_actions.pointer_action.move_to_location(end_x, end_y)

appium/webdriver/extensions/location.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def set_location(
6363
Union['WebDriver', 'Location']: Self instance
6464
"""
6565
data = {
66-
"location": {
67-
"latitude": latitude,
68-
"longitude": longitude,
66+
'location': {
67+
'latitude': latitude,
68+
'longitude': longitude,
6969
}
7070
}
7171
if altitude is not None:

appium/webdriver/extensions/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def update_settings(self, settings: Dict[str, Any]) -> 'WebDriver':
4242
Args:
4343
settings: dictionary of settings to apply to the current test session
4444
"""
45-
self.execute(Command.UPDATE_SETTINGS, {"settings": settings})
45+
self.execute(Command.UPDATE_SETTINGS, {'settings': settings})
4646
return cast('WebDriver', self)
4747

4848
def _add_commands(self) -> None:

appium/webdriver/webdriver.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def __init__(
285285
instance = extension(self.execute)
286286
method_name = instance.method_name()
287287
if hasattr(WebDriver, method_name):
288-
logger.debug(f"Overriding the method '{method_name}'")
288+
logger.debug(f'Overriding the method \'{method_name}\'')
289289

290290
# add a new method named 'instance.method_name()' and call it
291291
setattr(WebDriver, method_name, getattr(instance, method_name))
@@ -519,7 +519,7 @@ def orientation(self, value: str) -> None:
519519
if value.upper() in allowed_values:
520520
self.execute(Command.SET_SCREEN_ORIENTATION, {'orientation': value})
521521
else:
522-
raise WebDriverException("You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'")
522+
raise WebDriverException('You can only set the orientation to \'LANDSCAPE\' and \'PORTRAIT\'')
523523

524524
def assert_extension_exists(self, ext_name: str) -> 'WebDriver':
525525
"""

appium/webdriver/webelement.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def find_element(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = No
112112
# by = By.CSS_SELECTOR
113113
# value = '[name="%s"]' % value
114114

115-
return self._execute(RemoteCommand.FIND_CHILD_ELEMENT, {"using": by, "value": value})['value']
115+
return self._execute(RemoteCommand.FIND_CHILD_ELEMENT, {'using': by, 'value': value})['value']
116116

117117
def find_elements(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = None) -> List['WebElement']:
118118
"""Find elements given a AppiumBy strategy and locator
@@ -142,7 +142,7 @@ def find_elements(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = N
142142
# by = By.CSS_SELECTOR
143143
# value = '[name="%s"]' % value
144144

145-
return self._execute(RemoteCommand.FIND_CHILD_ELEMENTS, {"using": by, "value": value})['value']
145+
return self._execute(RemoteCommand.FIND_CHILD_ELEMENTS, {'using': by, 'value': value})['value']
146146

147147
def clear(self) -> 'WebElement':
148148
"""Clears text.

test/functional/android/activities_tests.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ def test_current_activity(self) -> None:
2222
assert '.ApiDemos' == activity
2323

2424
def test_start_activity_this_app(self) -> None:
25-
self.driver.start_activity(APIDEMO_PKG_NAME, ".ApiDemos")
25+
self.driver.start_activity(APIDEMO_PKG_NAME, '.ApiDemos')
2626
self._assert_activity_contains('Demos')
2727

28-
self.driver.start_activity(APIDEMO_PKG_NAME, ".accessibility.AccessibilityNodeProviderActivity")
28+
self.driver.start_activity(APIDEMO_PKG_NAME, '.accessibility.AccessibilityNodeProviderActivity')
2929
self._assert_activity_contains('Node')
3030

3131
def test_start_activity_other_app(self) -> None:
32-
self.driver.start_activity(APIDEMO_PKG_NAME, ".ApiDemos")
32+
self.driver.start_activity(APIDEMO_PKG_NAME, '.ApiDemos')
3333
self._assert_activity_contains('Demos')
3434

35-
self.driver.start_activity("com.google.android.deskclock", "com.android.deskclock.DeskClock")
35+
self.driver.start_activity('com.google.android.deskclock', 'com.android.deskclock.DeskClock')
3636
self._assert_activity_contains('Clock')
3737

3838
def _assert_activity_contains(self, activity: str) -> None:

test/functional/android/context_switching_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from .helper import desired_capabilities
2424

2525

26-
@pytest.mark.skip(reason="Need to fix broken test")
26+
@pytest.mark.skip(reason='Need to fix broken test')
2727
class TestContextSwitching(object):
2828
def setup_method(self) -> None:
2929
caps = desired_capabilities.get_desired_capabilities('selendroid-test-app.apk')
@@ -44,7 +44,7 @@ def test_move_to_correct_context(self) -> None:
4444
def test_actually_in_webview(self) -> None:
4545
self._enter_webview()
4646
self.driver.find_element(by=AppiumBy.CSS_SELECTOR, value='input[type=submit]').click()
47-
el = self.driver.find_element(by=AppiumBy.XPATH, value="//h1[contains(., 'This is my way')]")
47+
el = self.driver.find_element(by=AppiumBy.XPATH, value='//h1[contains(., \'This is my way\')]')
4848
assert el is not None
4949

5050
def test_move_back_to_native_context(self) -> None:

test/functional/android/helper/test_helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ def teardown_method(self, method) -> None: # type: ignore
4444
if is_ci():
4545
payload = self.driver.stop_recording_screen()
4646
video_path = os.path.join(os.getcwd(), method.__name__ + '.mp4')
47-
with open(video_path, "wb") as fd:
47+
with open(video_path, 'wb') as fd:
4848
fd.write(base64.b64decode(payload))
4949
self.driver.quit()

test/functional/android/search_context/find_by_image_tests.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def setup_method(self) -> None:
3232

3333
# relax template matching
3434
self.driver.update_settings(
35-
{"fixImageFindScreenshotDims": False, "fixImageTemplateSize": True, "autoUpdateImageElementPosition": True}
35+
{'fixImageFindScreenshotDims': False, 'fixImageTemplateSize': True, 'autoUpdateImageElementPosition': True}
3636
)
3737

3838
def teardown_method(self) -> None:
@@ -57,14 +57,14 @@ def test_find_based_on_image_template(self) -> None:
5757
assert rect['y'] is not None
5858
assert el.is_displayed()
5959
el.click()
60-
wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, "Alarm")
60+
wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, 'Alarm')
6161

6262
def test_find_multiple_elements_by_image_just_returns_one(self) -> None:
63-
wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, "App")
63+
wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, 'App')
6464
image_path = desired_capabilities.PATH('file/find_by_image_success.png')
6565
els = self.driver.find_elements_by_image(image_path)
6666
els[0].click()
67-
wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, "Alarm")
67+
wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, 'Alarm')
6868

6969
def test_find_throws_no_such_element(self) -> None:
7070
image_path = desired_capabilities.PATH('file/find_by_image_failure.png')

test/functional/android/search_context/find_by_uiautomator_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from test.functional.android.helper.test_helper import BaseTestCase
2020

2121

22-
@pytest.mark.skip(reason="Need to fix flaky test")
22+
@pytest.mark.skip(reason='Need to fix flaky test')
2323
class TestFindByUIAutomator(BaseTestCase):
2424
def test_find_single_element(self) -> None:
2525
el = self.driver.find_element(by=AppiumBy.ANDROID_UIAUTOMATOR, value='new UiSelector().text("Animation")')

test/functional/android/settings_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ def test_get_settings(self) -> None:
2222
assert settings is not None
2323

2424
def test_update_settings(self) -> None:
25-
self.driver.update_settings({"waitForIdleTimeout": 10001})
25+
self.driver.update_settings({'waitForIdleTimeout': 10001})
2626
settings = self.driver.get_settings()
27-
assert settings["waitForIdleTimeout"] == 10001
27+
assert settings['waitForIdleTimeout'] == 10001

test/functional/android/touch_action_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_tap_twice(self) -> None:
5151
action.tap(el, count=2).perform()
5252

5353
els = self.driver.find_elements(by=AppiumBy.CLASS_NAME, value='android.widget.TextView')
54-
assert 'This is a test\nThis is a test\n' == els[1].get_attribute("text")
54+
assert 'This is a test\nThis is a test\n' == els[1].get_attribute('text')
5555

5656
def test_press_and_immediately_release(self) -> None:
5757
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Animation')

test/functional/android/webelement_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_set_text(self) -> None:
4343

4444
def test_send_keys(self) -> None:
4545
for text in ['App', 'Activity', 'Custom Title']:
46-
wait_for_element(self.driver, AppiumBy.XPATH, f"//android.widget.TextView[@text='{text}']").click()
46+
wait_for_element(self.driver, AppiumBy.XPATH, f'//android.widget.TextView[@text=\'{text}\']').click()
4747

4848
el = wait_for_element(self.driver, AppiumBy.ID, '{}:id/left_text_edit'.format(APIDEMO_PKG_NAME))
4949
el.send_keys(' text')

test/functional/ios/applications_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ def test_app_management(self) -> None:
2828
self.driver.background_app(-1)
2929
assert wait_for_condition(
3030
lambda: self.driver.query_app_state(desired_capabilities.BUNDLE_ID) < ApplicationState.RUNNING_IN_FOREGROUND
31-
), "The app didn't go to background."
31+
), 'The app didn\'t go to background.'
3232
self.driver.activate_app(desired_capabilities.BUNDLE_ID)
3333
assert self.driver.query_app_state(desired_capabilities.BUNDLE_ID) == ApplicationState.RUNNING_IN_FOREGROUND

test/functional/ios/helper/test_helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ def teardown_method(self, method) -> None: # type: ignore
3737
if is_ci():
3838
payload = self.driver.stop_recording_screen()
3939
video_path = os.path.join(os.getcwd(), method.__name__ + '.mp4')
40-
with open(video_path, "wb") as fd:
40+
with open(video_path, 'wb') as fd:
4141
fd.write(base64.b64decode(payload))
4242
self.driver.quit()

test/functional/ios/safari_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_context(self) -> None:
3636
assert 'WEBVIEW_' in self.driver.current_context
3737

3838
def test_get(self) -> None:
39-
self.driver.get("http://google.com")
39+
self.driver.get('http://google.com')
4040
for _ in range(5):
4141
time.sleep(0.5)
4242
if 'Google' == self.driver.title:

test/functional/ios/webdriver_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_app_management(self) -> None:
6666
assert wait_for_condition(
6767
lambda: self.driver.query_app_state(desired_capabilities.BUNDLE_ID)
6868
< ApplicationState.RUNNING_IN_FOREGROUND,
69-
), "The app didn't go to background."
69+
), 'The app didn\'t go to background.'
7070
self.driver.activate_app(desired_capabilities.BUNDLE_ID)
7171
assert self.driver.query_app_state(desired_capabilities.BUNDLE_ID) == ApplicationState.RUNNING_IN_FOREGROUND
7272

@@ -97,7 +97,7 @@ def test_clear(self) -> None:
9797
assert text == def_text
9898

9999
def test_press_button(self) -> None:
100-
self.driver.press_button("Home")
100+
self.driver.press_button('Home')
101101
if float(desired_capabilities.get_desired_capabilities(desired_capabilities.BUNDLE_ID)['platformVersion']) < 11:
102102
return
103103
assert self.driver.query_app_state(desired_capabilities.BUNDLE_ID) == ApplicationState.RUNNING_IN_FOREGROUND

0 commit comments

Comments
 (0)