Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .config-pep8

This file was deleted.

4 changes: 0 additions & 4 deletions .isort.cfg

This file was deleted.

8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.4
rev: v1.5.2
hooks:
- id: autopep8
args: ["-a", "--global-config", ".config-pep8", "-i"]
args: ["-a", "-i"]
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.20
rev: v4.3.21
hooks:
- id: isort
args: ["-rc", "."]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.761'
rev: 'v0.770'
hooks:
- id: mypy
entry: mypy appium/ test/
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.PHONY: Commands for developers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding all?

Copy link
Collaborator Author

@ki4070ma ki4070ma May 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, added check-all command.

.PHONY: isort
isort: ## Run isort
python -m isort $(ARGS) -rc .

.PHONY: autopep8
autopep8: ## Run autopep8
python -m autopep8 $(ARGS) -a -r -i .

.PHONY: pylint
pylint: ## Run pylint
python -m pylint $(ARGS) --rcfile .pylintrc appium test

.PHONY: mypy
mypy: ## Run mypy
python -m mypy appium test

.PHONY: unittest
unittest: ## Run unittest
python -m pytest test/unit/

.PHONY: help
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ https://appium.github.io/python-client-sphinx/ is detailed documentation

- Code Style: [PEP-0008](https://www.python.org/dev/peps/pep-0008/)
- Apply `autopep8`, `isort` and `mypy` as pre commit hook
- Run `make` command for development. See `make help` output for details
- Docstring style: [Google Style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)
- `gitchangelog` generates `CHANGELOG.rst`

Expand Down
2 changes: 1 addition & 1 deletion appium/webdriver/extensions/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def events(self) -> Dict:
session = self.session
return session['events']
except Exception as e:
logger.warning('Could not find events information in the session. Error:', e)
logger.warning('Could not find events information in the session. Error: %s', e)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Notes] Fixed pylint error

return {}

# pylint: disable=protected-access
Expand Down
38 changes: 11 additions & 27 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
#!/bin/bash

set -o pipefail

EXIT_STATUS=0
if ! python -m autopep8 --exit-code -a -r --global-config .config-pep8 -i . ; then
echo "Please run command 'python -m autopep8 -a -r --global-config .config-pep8 -i .' on your local and commit the result"

if ! make autopep8 ARGS=--exit-code ; then
echo "Please run command 'make autopep8' on your local and commit the result"
EXIT_STATUS=1
fi

if ! python -m isort --check-only -rc . ; then
echo "Please run command 'python -m isort -rc .' on your local and commit the result"
if ! make isort ARGS=--check-only ; then
echo "Please run command 'make isort' on your local and commit the result"
EXIT_STATUS=1
fi

(
LINT_RESULT=$(python -m pylint --rcfile .pylintrc appium test --errors-only 2>&1 | tee /dev/tty)
if [[ $? -ne 0 ]] ; then
EXIT_STATUS=1
Copy link
Collaborator Author

@ki4070ma ki4070ma May 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Notes] This EXIT_STATUS scope is within subshell (()).

fi

# FIXME: pylint x Python 3.7 cause this runtime error.
# We must remove here when we drop Python 2 (and can update pylint) or
# install newer pylint for Python 3.7 environment on CI
if [[ $LINT_RESULT =~ "RuntimeError: generator raised StopIteration" ]] ; then
EXIT_STATUS=0
fi
)
if ! make pylint ARGS=--errors-only ; then
echo "Please run command 'make pylint' on your local and fix errors"
EXIT_STATUS=1
fi

(
python -m pytest test/unit/
)
if [[ $? -ne 0 ]] ; then
if ! make unittest ; then
EXIT_STATUS=1
fi

(
python -m mypy appium test
)
if [[ $? -ne 0 ]] ; then
if ! make mypy ; then
EXIT_STATUS=1
fi

Expand Down
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sphinx >= 3.0, <4.0
sphinx >= 3.0, <4.0
sphinx_rtd_theme < 1.0
8 changes: 8 additions & 0 deletions mypy.ini → setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[pep8]
max-line-length = 120

[isort]
multi_line_output = 3
known_third_party = dateutil,httpretty,pytest,selenium,setuptools,urllib3,mock,sauceclient
known_first_party = test,appium

[mypy]
check_untyped_defs = True
disallow_untyped_calls = True
Expand Down