Skip to content

Commit 8205776

Browse files
authored
chore: Updates docstring (appium#533)
* Updates docstring * Add description to Returns field * Remove type from docstring Since type hint already added to args * Set default lang to en * Change usage style in docstring * Updates * Remove rtype unnecessary anymore since type hint works for auto completion * tweak * Update return type * Restore types for keyword args * Remove types from Return field Except for property and TypeVar
1 parent 48ce293 commit 8205776

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+314
-352
lines changed

appium/common/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class NoSuchContextException(InvalidSwitchToTargetException):
2121
To find the current set of active contexts, you can get a list
2222
of the active contexts in the following way:
2323
24-
print driver.contexts
24+
print(driver.contexts)
2525
2626
"""
2727
pass

appium/common/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ def extract_const_attributes(cls: type) -> Dict[str, Any]:
2121
"""Return dict with constants attributes and values in the class(e.g. {'VAL1': 1, 'VAL2': 2})
2222
2323
Args:
24-
cls (type): Class to be extracted constants
24+
cls: Class to be extracted constants
2525
2626
Returns:
27-
dict: dict with constants attributes and values in the class
27+
dict with constants attributes and values in the class
2828
"""
2929
return dict([(attr, value) for attr, value in vars(cls).items()
3030
if not callable(getattr(cls, attr)) and attr.isupper()])

appium/webdriver/appium_service.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ def start(self, **kwargs: Any) -> sp.Popen:
128128
which is inherited from the parent process is assigned by default.
129129
node (str): The full path to the main NodeJS executable. The service will try
130130
to retrieve it automatically by default.
131-
stdout: Check on the documentation for subprocess.Popen for more details.
131+
stdout (int): Check on the documentation for subprocess.Popen for more details.
132132
The default value is subprocess.PIPE.
133-
stderr: Check on the documentation for subprocess.Popen for more details.
133+
stderr (int): Check on the documentation for subprocess.Popen for more details.
134134
The default value is subprocess.PIPE.
135135
timeout_ms (int): The maximum time to wait until Appium process starts listening
136136
for HTTP connections. If set to zero or a negative number then no wait will be applied.
@@ -143,10 +143,8 @@ def start(self, **kwargs: Any) -> sp.Popen:
143143
about possible arguments and their values.
144144
145145
Returns:
146-
subprocess.Popen instance: You can use Popen.communicate interface
147-
or stderr/stdout properties of the instance
148-
(stdout/stderr must not be set to None in such case)
149-
in order to retrieve the actual process output.
146+
You can use Popen.communicate interface or stderr/stdout properties
147+
of the instance (stdout/stderr must not be set to None in such case) in order to retrieve the actual process output.
150148
"""
151149
self.stop()
152150

@@ -182,7 +180,7 @@ def stop(self) -> bool:
182180
or has been already stopped.
183181
184182
Returns:
185-
bool: `True` if the service was running before being stopped
183+
`True` if the service was running before being stopped
186184
"""
187185
is_terminated = False
188186
if self.is_running:
@@ -197,7 +195,7 @@ def is_running(self) -> bool:
197195
"""Check if the service is running.
198196
199197
Returns:
200-
bool: `True` or `False`
198+
bool: `True` if the service is running
201199
"""
202200
return self._process is not None and self._process.poll() is None
203201

appium/webdriver/common/multi_action.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,17 @@ def add(self, *touch_actions: 'TouchAction') -> None:
4141
"""Add TouchAction objects to the MultiAction, to be performed later.
4242
4343
Args:
44-
touch_actions (`TouchAction`): one or more TouchAction objects describing a chain of actions to be performed by one finger
44+
touch_actions: one or more TouchAction objects describing a chain of actions to be performed by one finger
4545
4646
Usage:
47-
a1 = TouchAction(driver)
48-
49-
a1.press(el1).move_to(el2).release()
50-
51-
a2 = TouchAction(driver)
52-
53-
a2.press(el2).move_to(el1).release()
54-
55-
MultiAction(driver).add(a1, a2)
47+
| a1 = TouchAction(driver)
48+
| a1.press(el1).move_to(el2).release()
49+
| a2 = TouchAction(driver)
50+
| a2.press(el2).move_to(el1).release()
51+
| MultiAction(driver).add(a1, a2)
52+
53+
Returns:
54+
`MultiAction`: Self instance
5655
"""
5756
for touch_action in touch_actions:
5857
if self._touch_actions is None:
@@ -64,15 +63,14 @@ def perform(self: T) -> T:
6463
"""Perform the actions stored in the object.
6564
6665
Usage:
67-
a1 = TouchAction(driver)
68-
69-
a1.press(el1).move_to(el2).release()
70-
71-
a2 = TouchAction(driver)
72-
73-
a2.press(el2).move_to(el1).release()
74-
75-
MultiAction(driver).add(a1, a2).perform()
66+
| a1 = TouchAction(driver)
67+
| a1.press(el1).move_to(el2).release()
68+
| a2 = TouchAction(driver)
69+
| a2.press(el2).move_to(el1).release()
70+
| MultiAction(driver).add(a1, a2).perform()
71+
72+
Returns:
73+
`MultiAction`: Self instance
7674
"""
7775
self._driver.execute(Command.MULTI_ACTION, self.json_wire_gestures)
7876

appium/webdriver/common/touch_action.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def tap(self: T, element: Optional['WebElement'] = None, x: Optional[int]
4646
"""Perform a tap action on the element
4747
4848
Args:
49-
element (`appium.webdriver.webelement.WebElement`): the element to tap
50-
x (:obj:`int`, optional): x coordinate to tap, relative to the top left corner of the element.
51-
y (:obj:`int`, optional): y coordinate. If y is used, x must also be set, and vice versa
49+
element: the element to tap
50+
x : x coordinate to tap, relative to the top left corner of the element.
51+
y : y coordinate. If y is used, x must also be set, and vice versa
5252
5353
Returns:
54-
`TouchAction`: self instance
54+
`TouchAction`: Self instance
5555
"""
5656
opts = self._get_opts(element, x, y)
5757
opts['count'] = count
@@ -64,14 +64,14 @@ def press(self: T, el: Optional['WebElement'] = None, x: Optional[int] = None,
6464
"""Begin a chain with a press down action at a particular element or point
6565
6666
Args:
67-
el (:obj:`appium.webdriver.webelement.WebElement`, optional): the element to press
68-
x (:obj:`int`, optional): x coordiate to press. If y is used, x must also be set
69-
y (:obj:`int`, optional): y coordiate to press. If x is used, y must also be set
70-
pressure (:obj:`float`, optional): [iOS Only] press as force touch. Read the description of `force` property on Apple's UITouch class
67+
el: the element to press
68+
x: x coordiate to press. If y is used, x must also be set
69+
y: y coordiate to press. If x is used, y must also be set
70+
pressure: [iOS Only] press as force touch. Read the description of `force` property on Apple's UITouch class
7171
(https://developer.apple.com/documentation/uikit/uitouch?language=objc) for more details on possible value ranges.
7272
7373
Returns:
74-
`TouchAction`: self instance
74+
`TouchAction`: Self instance
7575
"""
7676
self._add_action('press', self._get_opts(el, x, y, pressure=pressure))
7777

@@ -82,13 +82,13 @@ def long_press(self: T, el: Optional['WebElement'] = None, x: Optional[int]
8282
"""Begin a chain with a press down that lasts `duration` milliseconds
8383
8484
Args:
85-
el (:obj:`appium.webdriver.webelement.WebElement`, optional): the element to press
86-
x (:obj:`int`, optional): x coordiate to press. If y is used, x must also be set
87-
y (:obj:`int`, optional): y coordiate to press. If x is used, y must also be set
88-
duration (:obj:`int`, optional): Duration to press
85+
el: the element to press
86+
x: x coordiate to press. If y is used, x must also be set
87+
y: y coordiate to press. If x is used, y must also be set
88+
duration: Duration to press
8989
9090
Returns:
91-
`TouchAction`: self instance
91+
`TouchAction`: Self instance
9292
"""
9393
self._add_action('longPress', self._get_opts(el, x, y, duration))
9494

@@ -98,10 +98,10 @@ def wait(self: T, ms: int = 0) -> T:
9898
"""Pause for `ms` milliseconds.
9999
100100
Args:
101-
ms (int): The time to pause
101+
ms: The time to pause
102102
103103
Returns:
104-
`TouchAction`: self instance
104+
`TouchAction`: Self instance
105105
"""
106106
if ms is None:
107107
ms = 0
@@ -116,12 +116,12 @@ def move_to(self: T, el: Optional['WebElement'] = None, x: Optional[int] = None,
116116
"""Move the pointer from the previous point to the element or point specified
117117
118118
Args:
119-
el (:obj:`appium.webdriver.webelement.WebElement`, optional): the element to be moved to
120-
x (:obj:`int`, optional): x coordiate to be moved to. If y is used, x must also be set
121-
y (:obj:`int`, optional): y coordiate to be moved to. If x is used, y must also be set
119+
el: the element to be moved to
120+
x: x coordiate to be moved to. If y is used, x must also be set
121+
y: y coordiate to be moved to. If x is used, y must also be set
122122
123123
Returns:
124-
`TouchAction`: self instance
124+
`TouchAction`: Self instance
125125
"""
126126
self._add_action('moveTo', self._get_opts(el, x, y))
127127

@@ -131,7 +131,7 @@ def release(self: T) -> T:
131131
"""End the action by lifting the pointer off the screen
132132
133133
Returns:
134-
`TouchAction`: self instance
134+
`TouchAction`: Self instance
135135
"""
136136
self._add_action('release', {})
137137

@@ -141,7 +141,7 @@ def perform(self: T) -> T:
141141
"""Perform the action by sending the commands to the server to be operated upon
142142
143143
Returns:
144-
`TouchAction`: self instance
144+
`TouchAction`: Self instance
145145
"""
146146
if self._driver is None:
147147
raise ValueError('Set driver to constructor as a argument when to create the instance.')

appium/webdriver/extensions/action_helpers.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def scroll(self: T, origin_el: WebElement, destination_el: WebElement, duration:
4242
driver.scroll(el1, el2)
4343
4444
Returns:
45-
`appium.webdriver.webelement.WebElement`
45+
Union['WebDriver', 'ActionHelpers']: Self instance
4646
"""
4747

4848
# XCUITest x W3C spec has no duration by default in server side
@@ -64,7 +64,7 @@ def drag_and_drop(self: T, origin_el: WebElement, destination_el: WebElement) ->
6464
destination_el: the element to drag to
6565
6666
Returns:
67-
`appium.webdriver.webelement.WebElement`
67+
Union['WebDriver', 'ActionHelpers']: Self instance
6868
"""
6969
action = TouchAction(self)
7070
action.long_press(origin_el).move_to(destination_el).release().perform()
@@ -75,15 +75,15 @@ def tap(self: T, positions: List[Tuple[int, int]], duration: Optional[int] = Non
7575
certain time
7676
7777
Args:
78-
positions (:obj:`list` of :obj:`tuple`): an array of tuples representing the x/y coordinates of
78+
positions: an array of tuples representing the x/y coordinates of
7979
the fingers to tap. Length can be up to five.
80-
duration (:obj:`int`, optional): length of time to tap, in ms
80+
duration: length of time to tap, in ms
8181
8282
Usage:
8383
driver.tap([(100, 20), (100, 60), (100, 100)], 500)
8484
8585
Returns:
86-
`appium.webdriver.webelement.WebElement`
86+
Union['WebDriver', 'ActionHelpers']: Self instance
8787
"""
8888
if len(positions) == 1:
8989
action = TouchAction(self)
@@ -113,17 +113,17 @@ def swipe(self: T, start_x: int, start_y: int, end_x: int, end_y: int, duration:
113113
"""Swipe from one point to another point, for an optional duration.
114114
115115
Args:
116-
start_x (int): x-coordinate at which to start
117-
start_y (int): y-coordinate at which to start
118-
end_x (int): x-coordinate at which to stop
119-
end_y (int): y-coordinate at which to stop
120-
duration (:obj:`int`, optional): time to take the swipe, in ms.
116+
start_x: x-coordinate at which to start
117+
start_y: y-coordinate at which to start
118+
end_x: x-coordinate at which to stop
119+
end_y: y-coordinate at which to stop
120+
duration: time to take the swipe, in ms.
121121
122122
Usage:
123123
driver.swipe(100, 100, 100, 400)
124124
125125
Returns:
126-
`appium.webdriver.webelement.WebElement`
126+
Union['WebDriver', 'ActionHelpers']: Self instance
127127
"""
128128
# `swipe` is something like press-wait-move_to-release, which the server
129129
# will translate into the correct action
@@ -140,16 +140,16 @@ def flick(self: T, start_x: int, start_y: int, end_x: int, end_y: int) -> T:
140140
"""Flick from one point to another point.
141141
142142
Args:
143-
start_x (int): x-coordinate at which to start
144-
start_y (int): y-coordinate at which to start
145-
end_x (int): x-coordinate at which to stop
146-
end_y (int): y-coordinate at which to stop
143+
start_x: x-coordinate at which to start
144+
start_y: y-coordinate at which to start
145+
end_x: x-coordinate at which to stop
146+
end_y: y-coordinate at which to stop
147147
148148
Usage:
149149
driver.flick(100, 100, 100, 400)
150150
151151
Returns:
152-
`appium.webdriver.webelement.WebElement`
152+
Union['WebDriver', 'ActionHelpers']: Self instance
153153
"""
154154
action = TouchAction(self)
155155
action \

appium/webdriver/extensions/android/activities.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def start_activity(self: T, app_package: str, app_activity: str, **opts: str) ->
3535
This is an Android-only method.
3636
3737
Args:
38-
app_package (str): The package containing the activity to start.
39-
app_activity (str): The activity to start.
38+
app_package: The package containing the activity to start.
39+
app_activity: The activity to start.
4040
4141
Keyword Args:
4242
app_wait_package (str): Begin automation after this package starts.
@@ -81,12 +81,12 @@ def wait_activity(self: T, activity: str, timeout: int, interval: int = 1) -> bo
8181
This is an Android-only method.
8282
8383
Args:
84-
activity (str): target activity
85-
timeout (int): max wait time, in seconds
86-
interval (int): sleep interval between retries, in seconds
84+
activity: target activity
85+
timeout: max wait time, in seconds
86+
interval: sleep interval between retries, in seconds
8787
8888
Returns:
89-
bool: `True` if the target activity is shown
89+
`True` if the target activity is shown
9090
"""
9191
try:
9292
WebDriverWait(self, timeout, interval).until(

appium/webdriver/extensions/android/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def end_test_coverage(self: T, intent: str, path: str) -> Any: # TODO Check ret
3434
See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/android-coverage.md
3535
3636
Args:
37-
intent (str): description of operation to be performed
38-
path (str): path to coverage.ec file to be pulled from the device
37+
intent: description of operation to be performed
38+
path: path to coverage.ec file to be pulled from the device
3939
4040
Returns:
4141
TODO
@@ -50,7 +50,7 @@ def open_notifications(self: T) -> T:
5050
"""Open notification shade in Android (API Level 18 and above)
5151
5252
Returns:
53-
`appium.webdriver.webdriver.WebDriver`
53+
Union['WebDriver', 'Common']: Self instance
5454
"""
5555
self.execute(Command.OPEN_NOTIFICATIONS, {})
5656
return self

appium/webdriver/extensions/android/display.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ def get_display_density(self: T) -> int:
3131
"""Get the display density, Android only
3232
3333
Returns:
34-
int: The display density of the Android device(dpi)
34+
The display density of the Android device(dpi)
3535
3636
Usage:
3737
self.driver.get_display_density()
38+
39+
Return:
40+
int: The display density
3841
"""
3942
return self.execute(Command.GET_DISPLAY_DENSITY)['value']
4043

0 commit comments

Comments
 (0)