Skip to content

Commit 69396f9

Browse files
authored
chore: Applied some py3 formats (#486)
* Removed unused import * Removed unnecessary codes * Applied f'' format instead ''.format() * Fixes * tweak
1 parent fbe9e11 commit 69396f9

25 files changed

+39
-50
lines changed

appium/saucetestcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020
import sys
2121
import unittest
22-
from typing import Any, Callable, List
22+
from typing import Callable, List
2323

2424
from sauceclient import SauceClient
2525

appium/webdriver/appium_service.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def poll_url(host: str, port: int, path: str, timeout_ms: int) -> bool:
5050
while time.time() < time_started_sec + timeout_ms / 1000.0:
5151
try:
5252
conn = urllib3.PoolManager(timeout=1.0)
53-
resp = conn.request('HEAD', 'http://{host}:{port}{path}'.format(
54-
host=host, port=port, path=path))
53+
resp = conn.request('HEAD', f'http://{host}:{port}{path}')
5554
if resp.status < 400:
5655
return True
5756
except Exception:
@@ -67,7 +66,7 @@ class AppiumServiceError(RuntimeError):
6766
T = TypeVar('T', bound='AppiumService')
6867

6968

70-
class AppiumService(object):
69+
class AppiumService:
7170
def __init__(self) -> None:
7271
self._process: Optional[sp.Popen] = None
7372
self._cmd: Optional[List] = None
@@ -169,13 +168,12 @@ def start(self, **kwargs: Any) -> sp.Popen:
169168
port = self._parse_port(args)
170169
error_msg: Optional[str] = None
171170
if not self.is_running or (timeout_ms > 0 and not poll_url(host, port, STATUS_URL, timeout_ms)):
172-
error_msg = 'Appium has failed to start on {}:{} within {}ms timeout'\
173-
.format(host, port, timeout_ms)
171+
error_msg = f'Appium has failed to start on {host}:{port} within {timeout_ms}ms timeout'
174172
if error_msg is not None:
175173
if stderr == sp.PIPE:
176174
err_output = self._process.stderr.read()
177175
if err_output:
178-
error_msg += '\nOriginal error: {}'.format(str(err_output))
176+
error_msg += f'\nOriginal error: {str(err_output)}'
179177
self.stop()
180178
raise AppiumServiceError(error_msg)
181179
return self._process

appium/webdriver/applicationstate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515

16-
class ApplicationState(object):
16+
class ApplicationState:
1717
NOT_INSTALLED = 0
1818
NOT_RUNNING = 1
1919
RUNNING_IN_BACKGROUND_SUSPENDED = 2

appium/webdriver/clipboard_content_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515

16-
class ClipboardContentType(object):
16+
class ClipboardContentType:
1717
PLAINTEXT = 'plaintext'
1818
IMAGE = 'image'
1919
URL = 'url'

appium/webdriver/common/multi_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
T = TypeVar('T', bound='MultiAction')
3232

3333

34-
class MultiAction(object):
34+
class MultiAction:
3535
def __init__(self, driver: 'WebDriver', element: Optional['WebElement'] = None) -> None:
3636
self._driver = driver
3737
self._element = element

appium/webdriver/common/touch_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
T = TypeVar('T', bound='TouchAction')
3636

3737

38-
class TouchAction(object):
38+
class TouchAction:
3939

4040
def __init__(self, driver: Optional['WebDriver'] = None):
4141
self._driver = driver

appium/webdriver/connectiontype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"""
2727

2828

29-
class ConnectionType(object):
29+
class ConnectionType:
3030
NO_CONNECTION = 0
3131
AIRPLANE_MODE = 1
3232
WIFI_ONLY = 2

appium/webdriver/extensions/android/display.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import TypeVar
16-
1715
from selenium import webdriver
1816

1917
from appium.webdriver.mobilecommand import MobileCommand as Command

appium/webdriver/extensions/android/gsm.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
from appium.webdriver.mobilecommand import MobileCommand as Command
2222

2323

24-
class GsmCallActions(object):
24+
class GsmCallActions:
2525
CALL = 'call'
2626
ACCEPT = 'accept'
2727
CANCEL = 'cancel'
2828
HOLD = 'hold'
2929

3030

31-
class GsmSignalStrength(object):
31+
class GsmSignalStrength:
3232
NONE_OR_UNKNOWN = 0
3333
POOR = 1
3434
MODERATE = 2
3535
GOOD = 3
3636
GREAT = 4
3737

3838

39-
class GsmVoiceState(object):
39+
class GsmVoiceState:
4040
UNREGISTERED = 'unregistered'
4141
HOME = 'home'
4242
ROAMING = 'roaming'
@@ -66,8 +66,8 @@ def make_gsm_call(self, phone_number: str, action: str) -> T:
6666
"""
6767
constants = extract_const_attributes(GsmCallActions)
6868
if action not in constants.values():
69-
logger.warning('{} is unknown. Consider using one of {} constants. (e.g. {}.CALL)'.format(
70-
action, list(constants.keys()), GsmCallActions.__name__))
69+
logger.warning(
70+
f'{action} is unknown. Consider using one of {list(constants.keys())} constants. (e.g. {GsmCallActions.__name__}.CALL)')
7171
self.execute(Command.MAKE_GSM_CALL, {'phoneNumber': phone_number, 'action': action})
7272
return self
7373

@@ -85,8 +85,8 @@ def set_gsm_signal(self, strength: int) -> T:
8585
"""
8686
constants = extract_const_attributes(GsmSignalStrength)
8787
if strength not in constants.values():
88-
logger.warning('{} is out of range. Consider using one of {} constants. (e.g. {}.GOOD)'.format(
89-
strength, list(constants.keys()), GsmSignalStrength.__name__))
88+
logger.warning(
89+
f'{strength} is out of range. Consider using one of {list(constants.keys())} constants. (e.g. {GsmSignalStrength.__name__}.GOOD)')
9090
self.execute(Command.SET_GSM_SIGNAL, {'signalStrength': strength, 'signalStrengh': strength})
9191
return self
9292

@@ -104,8 +104,8 @@ def set_gsm_voice(self, state: str) -> T:
104104
"""
105105
constants = extract_const_attributes(GsmVoiceState)
106106
if state not in constants.values():
107-
logger.warning('{} is unknown. Consider using one of {} constants. (e.g. {}.HOME)'.format(
108-
state, list(constants.keys()), GsmVoiceState.__name__))
107+
logger.warning(
108+
f'{state} is unknown. Consider using one of {list(constants.keys())} constants. (e.g. {GsmVoiceState.__name__}.HOME)')
109109
self.execute(Command.SET_GSM_VOICE, {'state': state})
110110
return self
111111

appium/webdriver/extensions/android/network.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Any, TypeVar
15+
from typing import TypeVar
1616

1717
from selenium import webdriver
1818

@@ -23,7 +23,7 @@
2323
T = TypeVar('T', bound='Network')
2424

2525

26-
class NetSpeed(object):
26+
class NetSpeed:
2727
GSM = 'gsm' # GSM/CSD (up: 14.4(kbps), down: 14.4(kbps))
2828
SCSD = 'scsd' # HSCSD (up: 14.4, down: 57.6)
2929
GPRS = 'gprs' # GPRS (up: 28.8, down: 57.6)
@@ -98,8 +98,8 @@ def set_network_speed(self, speed_type: str) -> T:
9898
"""
9999
constants = extract_const_attributes(NetSpeed)
100100
if speed_type not in constants.values():
101-
logger.warning('{} is unknown. Consider using one of {} constants. (e.g. {}.LTE)'.format(
102-
speed_type, list(constants.keys()), NetSpeed.__name__))
101+
logger.warning(
102+
f'{speed_type} is unknown. Consider using one of {list(constants.keys())} constants. (e.g. {NetSpeed.__name__}.LTE)')
103103

104104
self.execute(Command.SET_NETWORK_SPEED, {'netspeed': speed_type})
105105
return self

0 commit comments

Comments
 (0)