Skip to content

Commit f8d600e

Browse files
authored
add autopep8 (appium#243)
* apply autopep8 * add development section as the first draft * relax max-line-length * add global-config
1 parent b6bdf5f commit f8d600e

20 files changed

Lines changed: 75 additions & 39 deletions

.config-pep8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pep8]
2+
max-line-length = 120

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ install:
77
- pip install -r ci-requirements.txt
88

99
script:
10-
- python -m pylint --rcfile .pylintrc appium test --py3k
11-
- python -m pytest test/unit/*
10+
- ./ci.sh

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ download and unarchive the source tarball (Appium-Python-Client-X.X.tar.gz).
3737
python setup.py install
3838
```
3939

40+
# Development
41+
42+
- Style Guide: https://www.python.org/dev/peps/pep-0008/
43+
- `autopep8` helps to format code automatically
44+
45+
```
46+
$ python -m autopep8 -r --global-config .config-pep8 -i .
47+
```
4048
4149
# Usage
4250

appium/saucetestcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def decorator(base_class):
3232
module = sys.modules[base_class.__module__].__dict__
3333
for i, platform in enumerate(platforms):
3434
name = "%s_%s" % (base_class.__name__, i + 1)
35-
d_caps = {'desired_capabilities' : platform}
35+
d_caps = {'desired_capabilities': platform}
3636
module[name] = type(name, (base_class,), d_caps)
3737
return decorator
3838

appium/webdriver/connectiontype.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
4 (Data only) | 1 | 0 | 0
2525
6 (All network on) | 1 | 1 | 0
2626
"""
27+
28+
2729
class ConnectionType(object):
2830
NO_CONNECTION = 0
2931
AIRPLANE_MODE = 1

appium/webdriver/imagelement.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import math
1616

17+
1718
class ImageElement(object):
1819

1920
def __init__(self, driver, x, y, width, height):

appium/webdriver/mobilecommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MobileCommand(object):
3434
# Appium Commands
3535
GET_APP_STRINGS = 'getAppStrings'
3636
PRESS_KEYCODE = 'pressKeyCode'
37-
KEY_EVENT = 'keyEvent' # Needed for Selendroid
37+
KEY_EVENT = 'keyEvent' # Needed for Selendroid
3838
LONG_PRESS_KEYCODE = 'longPressKeyCode'
3939
GET_CURRENT_ACTIVITY = 'getCurrentActivity'
4040
GET_CURRENT_PACKAGE = 'getCurrentPackage'

appium/webdriver/webdriver.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
from selenium.webdriver.common.by import By
2323
from selenium.webdriver.support.ui import WebDriverWait
24-
from selenium.common.exceptions import (TimeoutException, WebDriverException, InvalidArgumentException, NoSuchElementException)
24+
from selenium.common.exceptions import (TimeoutException, WebDriverException,
25+
InvalidArgumentException, NoSuchElementException)
2526

2627
from selenium.webdriver.remote.command import Command as RemoteCommand
2728

@@ -63,6 +64,8 @@
6364

6465
# override
6566
# Add appium prefix for the non-W3C capabilities
67+
68+
6669
def _make_w3c_caps(caps):
6770
appium_prefix = 'appium:'
6871

@@ -204,17 +207,17 @@ def find_element(self, by=By.ID, value=None):
204207
:rtype: WebElement
205208
"""
206209
# if self.w3c:
207-
# if by == By.ID:
208-
# by = By.CSS_SELECTOR
209-
# value = '[id="%s"]' % value
210-
# elif by == By.TAG_NAME:
211-
# by = By.CSS_SELECTOR
212-
# elif by == By.CLASS_NAME:
213-
# by = By.CSS_SELECTOR
214-
# value = ".%s" % value
215-
# elif by == By.NAME:
216-
# by = By.CSS_SELECTOR
217-
# value = '[name="%s"]' % value
210+
# if by == By.ID:
211+
# by = By.CSS_SELECTOR
212+
# value = '[id="%s"]' % value
213+
# elif by == By.TAG_NAME:
214+
# by = By.CSS_SELECTOR
215+
# elif by == By.CLASS_NAME:
216+
# by = By.CSS_SELECTOR
217+
# value = ".%s" % value
218+
# elif by == By.NAME:
219+
# by = By.CSS_SELECTOR
220+
# value = '[name="%s"]' % value
218221
if by == By.IMAGE:
219222
return self.find_element_by_image(value)
220223

@@ -233,17 +236,17 @@ def find_elements(self, by=By.ID, value=None):
233236
:rtype: list of WebElement
234237
"""
235238
# if self.w3c:
236-
# if by == By.ID:
237-
# by = By.CSS_SELECTOR
238-
# value = '[id="%s"]' % value
239-
# elif by == By.TAG_NAME:
240-
# by = By.CSS_SELECTOR
241-
# elif by == By.CLASS_NAME:
242-
# by = By.CSS_SELECTOR
243-
# value = ".%s" % value
244-
# elif by == By.NAME:
245-
# by = By.CSS_SELECTOR
246-
# value = '[name="%s"]' % value
239+
# if by == By.ID:
240+
# by = By.CSS_SELECTOR
241+
# value = '[id="%s"]' % value
242+
# elif by == By.TAG_NAME:
243+
# by = By.CSS_SELECTOR
244+
# elif by == By.CLASS_NAME:
245+
# by = By.CSS_SELECTOR
246+
# value = ".%s" % value
247+
# elif by == By.NAME:
248+
# by = By.CSS_SELECTOR
249+
# value = '[name="%s"]' % value
247250

248251
# Return empty list if driver returns null
249252
# See https://github.com/SeleniumHQ/selenium/issues/4555
@@ -1408,8 +1411,8 @@ def battery_info(self):
14081411
"""
14091412
return self.execute_script('mobile: batteryInfo')
14101413

1411-
14121414
# pylint: disable=protected-access
1415+
14131416
def _addCommands(self):
14141417
self.command_executor._commands[Command.CONTEXTS] = \
14151418
('GET', '/session/$sessionId/contexts')

appium/webdriver/webelement.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from .mobilecommand import MobileCommand as Command
1919

20+
2021
class WebElement(SeleniumWebElement):
2122
def find_element_by_ios_uiautomation(self, uia_string):
2223
"""Finds an element by uiautomation in iOS.

ci-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ selenium
22
astroid
33
isort
44
pylint
5+
autopep8

0 commit comments

Comments
 (0)