Skip to content

Commit 9c597a3

Browse files
ki4070madependabot-preview[bot]KazuCocoamykola-mokhnachiamnrupesh
authored
feat: Merge python3 branch to master (#526)
* Drop py2 support (#478) * Drop py2 support * Support 3.7+ * Add explicit type declarations (#482) * Fixed mypy warning: touch_action.py * Fixed mypy warning: multi_action.py * Fixed mypy warning: extensions/android * Fixed mypy warning: extensions/search_context * Updated * Revert some changes to run unit test * Review comments * Updates * Updates * Add mypy check to ci.sh * Add mypy to Pipfile * Updates * Update README * Revert unexpected changes * Updates Dict * Revert unexpected changes * Updates * Review comments * Review comments * tweak * Restore and modify changes * Fix wrong return type * Add comments * Revert unexpected changes * Fix mypy error * updates * Add mypy to pre-commit (#485) * chore: Applied some py3 formats (#486) * Removed unused import * Removed unnecessary codes * Applied f'' format instead ''.format() * Fixes * tweak * chore: Fix mypy errors under test folder (#487) * Fix mypy errors under test folder * Add mypy check for test folder to pre-commit * Add mypy check to ci * chore: Remove unittest dependency (#488) * Removed unnecessary codes from calling super * Removed unittest dependency * Upgrade the dependencies to the latest * Removed unused args * Review comments * Update mock requirement from ~=3.0 to ~=4.0 (#502) Updates the requirements on [mock](https://github.com/testing-cabal/mock) to permit the latest version. - [Release notes](https://github.com/testing-cabal/mock/releases) - [Changelog](https://github.com/testing-cabal/mock/blob/master/CHANGELOG.rst) - [Commits](testing-cabal/mock@3.0.0...4.0.0) Signed-off-by: dependabot-preview[bot] <[email protected]> * Add 'from' to except (#503) * Update pre-commit requirement from ~=1.21 to ~=2.1 (#506) Updates the requirements on [pre-commit](https://github.com/pre-commit/pre-commit) to permit the latest version. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md) - [Commits](pre-commit/pre-commit@v1.21.0...v2.1.0) Signed-off-by: dependabot-preview[bot] <[email protected]> * doc: Add script to generate sphinx doc (#508) * Add quickstart template files * Update conf file * Update * Update settings * Change project name * Add script to generate docs * Changed header title * Add new line to usage section * Add py.typed file(PEP561) * Replace \n with new line * tweak * Use sphinx format for tables * Rebase python3 branch with master (#522) * Update pytest-cov requirement from ~=2.6 to ~=2.8 (#489) Updates the requirements on [pytest-cov](https://github.com/pytest-dev/pytest-cov) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest-cov/releases) - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](pytest-dev/pytest-cov@v2.6.0...v2.8.1) Signed-off-by: dependabot-preview[bot] <[email protected]> * Update autopep8 requirement from ~=1.4 to ~=1.5 (#490) Updates the requirements on [autopep8](https://github.com/hhatto/autopep8) to permit the latest version. - [Release notes](https://github.com/hhatto/autopep8/releases) - [Commits](hhatto/autopep8@v1.4...v1.5) Signed-off-by: dependabot-preview[bot] <[email protected]> * Update tox-travis requirement from ~=0.11 to ~=0.12 (#491) Updates the requirements on [tox-travis](https://github.com/tox-dev/tox-travis) to permit the latest version. - [Release notes](https://github.com/tox-dev/tox-travis/releases) - [Changelog](https://github.com/tox-dev/tox-travis/blob/master/HISTORY.rst) - [Commits](tox-dev/tox-travis@0.11...0.12) Signed-off-by: dependabot-preview[bot] <[email protected]> * Update tox requirement from ~=3.6 to ~=3.14 (#494) Updates the requirements on [tox](https://github.com/tox-dev/tox) to permit the latest version. - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst) - [Commits](tox-dev/tox@3.6.0...3.14.3) Signed-off-by: dependabot-preview[bot] <[email protected]> * chore: Fix find_by_images_tests.py (#495) * chore: Fix find_by_images_tests.py * Add installation opencv4nodejs * Fix typo * Add taking screen record to find_by_image_test * Fix errors on the emulator * Remove unused imports * feat: Add viewmatcher (#480) * Add android view matcher as strategy locator * Add docstring * Add functional test * Remove find_elements_by_android_data_matcher * Fix docstring * tweak docstring * Bump 0.50 * Update changelog for 0.50 * Fix flaky functional tests (#473) * Run all tests * Fix apk file path * Skip find_element_by_image test cases * Skip context switching test * Skip multi tap test on CI * Change strategy for waiting element * Add functions for same steps * Restore unexpected changes * Fix touch_action_tests * Fix * Fix Fix test_driver_swipe * fix * Create _move_to_[target_view] * [test_driver_swipe] Add wait * feat: Add idempotency key header to create session requests (#514) * feat: Override send_keys without file upload function (#515) * add send_keys_direct * override send_keys * tune * add unittest instead of functional test * tweak syntax * Bump 0.51 * Update changelog for 0.51 * test: Fix test_clear flaky functional test (#519) * test: Add unit test for set_value (setImmediateValue) (#518) * chore: Fix int - str comparison error in ios desired capabilities (#517) if number >= PytestXdistWorker.COUNT: TypeError: '>=' not supported between instances of 'int' and 'str' 2. Updated test case path and iPhone model in Readme file * fix: Handling of dictionary-values in WebElement.get_attribute() (#521) * Bump 0.52 * Update changelog for 0.52 * Fix mypy error * tweak * Add wait to test * Skip tap_twice test * review comments * Remove unnecessary import Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Kazuaki Matsuo <[email protected]> Co-authored-by: Mykola Mokhnach <[email protected]> Co-authored-by: Nrupesh Patel <[email protected]> Co-authored-by: Venkatesh <[email protected]> Co-authored-by: Hannes Hauer <[email protected]> * chore: Update readme and gitchangelog section role (#524) (#525) * chore: tweak changelog filter * address stoping Python 2 support * 2 instead of 2.0... * tweak readme * Revert some unexpected changes * review comments * Changed bound for TypeVar * Fix crashing ci * Remove beta Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Kazuaki Matsuo <[email protected]> Co-authored-by: Mykola Mokhnach <[email protected]> Co-authored-by: Nrupesh Patel <[email protected]> Co-authored-by: Venkatesh <[email protected]> Co-authored-by: Hannes Hauer <[email protected]>
1 parent 4c1bae6 commit 9c597a3

File tree

113 files changed

+1628
-955
lines changed

Some content is hidden

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

113 files changed

+1628
-955
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*._*
66
*.log
77
*.log.*
8+
_*/
89

910
*.pyc
1011
*.egg-info
@@ -14,10 +15,12 @@ MANIFEST
1415
build
1516
dist
1617

18+
# Cache
1719
.cache
1820
__pycache__
1921
.idea
2022
.pytest_cache
23+
.mypy_cache
2124

2225
# Virtual Environments
2326
venv*

.pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@
88
hooks:
99
- id: isort
1010
args: ["-rc", "."]
11+
- repo: https://github.com/pre-commit/mirrors-mypy
12+
rev: 'v0.761'
13+
hooks:
14+
- id: mypy
15+
entry: mypy appium/ test/
16+
pass_filenames: false

.travis.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ language: python
22
dist: xenial
33

44
python:
5-
- "2.7"
6-
- "3.4"
7-
- "3.5"
8-
- "3.6"
95
- "3.7"
10-
# - "3.8-dev" # TODO Remove comment-out when pylint and astroid upgraded to the latest and py2 support dropped
6+
- "3.8"
117

128
install:
139
- pip install tox-travis

Pipfile

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@ url = "https://pypi.org/simple"
44
verify_ssl = true
55

66
[dev-packages]
7-
pre-commit = "~=1.13"
7+
pre-commit = "~=2.1"
88

99
[packages]
1010
selenium = "~=3.141"
1111

1212
autopep8 = "~=1.5"
1313

14-
pytest = "~=4.0"
14+
pytest = "~=5.3"
1515
pytest-cov = "~=2.8"
1616

1717
tox = "~=3.14"
1818
tox-travis = "~=0.12"
1919

2020
httpretty = "~=0.9"
2121
python-dateutil = "~=2.8"
22-
mock = "~=3.0"
22+
mock = "~=4.0"
2323

24-
# TODO Update to the latest ver when py2 support dropped
25-
pylint = "~=1.9"
26-
astroid = "~=1.6"
24+
pylint = "~=2.4"
25+
astroid = "~=2.3"
2726
isort = "~=4.3"
27+
28+
mypy = "==0.761"

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,18 @@ download and unarchive the source tarball (Appium-Python-Client-X.X.tar.gz).
4949

5050
- Style Guide: https://www.python.org/dev/peps/pep-0008/
5151
- `autopep8` helps to format code automatically
52-
```
52+
```shell
5353
$ python -m autopep8 -r --global-config .config-pep8 -i .
5454
```
5555
- `isort` helps to order imports automatically
56-
```
56+
```shell
5757
$ python -m isort -rc .
5858
```
5959
- When you use newly 3rd party modules, add it to [.isort.cfg](.isort.cfg) to keep import order correct
60+
- `mypy` helps to check explicit type declarations
61+
```shell
62+
$ python -m mypy appium
63+
```
6064
- Docstring style: Google Style
6165
- Refer [link](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)
6266
- You can customise `CHANGELOG.rst` with commit messages following [.gitchangelog.rc](.gitchangelog.rc)

appium/common/helper.py

+6-25
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,25 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from collections import OrderedDict
15+
from typing import Any, Dict
1616

1717
from appium import version as appium_version
1818

1919

20-
def appium_bytes(value, encoding):
21-
"""Return a bytes-like object
22-
23-
Has _appium_ prefix to avoid overriding built-in bytes.
24-
25-
Args:
26-
value (str): A value to convert
27-
encoding (str): A encoding which will convert to
28-
29-
Returns:
30-
str: A bytes-like object
31-
"""
32-
33-
try:
34-
return bytes(value, encoding) # Python 3
35-
except TypeError:
36-
return value # Python 2
37-
38-
39-
def extract_const_attributes(cls):
20+
def extract_const_attributes(cls: type) -> Dict[str, Any]:
4021
"""Return dict with constants attributes and values in the class(e.g. {'VAL1': 1, 'VAL2': 2})
4122
4223
Args:
4324
cls (type): Class to be extracted constants
4425
4526
Returns:
46-
OrderedDict: dict with constants attributes and values in the class
27+
dict: dict with constants attributes and values in the class
4728
"""
48-
return OrderedDict(
49-
[(attr, value) for attr, value in vars(cls).items() if not callable(getattr(cls, attr)) and attr.isupper()])
29+
return dict([(attr, value) for attr, value in vars(cls).items()
30+
if not callable(getattr(cls, attr)) and attr.isupper()])
5031

5132

52-
def library_version():
33+
def library_version() -> str:
5334
"""Return a version of this python library
5435
"""
5536

appium/common/logger.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import sys
1717

1818

19-
def setup_logger(level=logging.NOTSET):
19+
def setup_logger(level: int = logging.NOTSET) -> None:
2020
logger.propagate = False
2121
logger.setLevel(level)
2222
handler = logging.StreamHandler(stream=sys.stderr)

appium/saucetestcase.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import os
2020
import sys
2121
import unittest
22+
from typing import Callable, List
2223

2324
from sauceclient import SauceClient
2425

@@ -29,8 +30,8 @@
2930
sauce = SauceClient(SAUCE_USERNAME, SAUCE_ACCESS_KEY)
3031

3132

32-
def on_platforms(platforms):
33-
def decorator(base_class):
33+
def on_platforms(platforms: List[str]) -> Callable[[type], None]:
34+
def decorator(base_class: type) -> None:
3435
module = sys.modules[base_class.__module__].__dict__
3536
for i, platform in enumerate(platforms):
3637
name = "%s_%s" % (base_class.__name__, i + 1)
@@ -40,16 +41,16 @@ def decorator(base_class):
4041

4142

4243
class SauceTestCase(unittest.TestCase):
43-
def setUp(self):
44-
self.desired_capabilities['name'] = self.id()
44+
def setUp(self) -> None:
45+
self.desired_capabilities['name'] = self.id() # type: ignore
4546
sauce_url = "http://%s:%[email protected]:80/wd/hub"
4647
self.driver = webdriver.Remote(
47-
desired_capabilities=self.desired_capabilities,
48+
desired_capabilities=self.desired_capabilities, # type: ignore
4849
command_executor=sauce_url % (SAUCE_USERNAME, SAUCE_ACCESS_KEY)
4950
)
5051
self.driver.implicitly_wait(30)
5152

52-
def tearDown(self):
53+
def tearDown(self) -> None:
5354
print("Link to your job: https://saucelabs.com/jobs/%s" % self.driver.session_id)
5455
try:
5556
if sys.exc_info() == (None, None, None):

appium/webdriver/appium_connection.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@
1313
# limitations under the License.
1414

1515
import uuid
16+
from typing import TYPE_CHECKING, Any, Dict
1617

1718
from selenium.webdriver.remote.remote_connection import RemoteConnection
1819

1920
from appium.common.helper import library_version
2021

22+
if TYPE_CHECKING:
23+
from urllib.parse import ParseResult
24+
2125

2226
class AppiumConnection(RemoteConnection):
2327

2428
@classmethod
25-
def get_remote_connection_headers(cls, parsed_url, keep_alive=True):
29+
def get_remote_connection_headers(cls, parsed_url: 'ParseResult', keep_alive: bool = True) -> Dict[str, Any]:
2630
"""Override get_remote_connection_headers in RemoteConnection"""
2731
headers = RemoteConnection.get_remote_connection_headers(parsed_url, keep_alive=keep_alive)
2832
headers['User-Agent'] = 'appium/python {} ({})'.format(library_version(), headers['User-Agent'])

0 commit comments

Comments
 (0)