diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1fa98df..78fdc88 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,8 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 mypy - pip install -r tests/requirements.txt + pip install -r requirements.txt - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.travis.yml b/.travis.yml index 85cd8be..c235c46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,7 @@ python: - "3.9" # command to install dependencies install: - - pip install flake8 - - pip install mypy - - pip install -r tests/requirements.txt + - pip install -r requirements-dev.txt # check PEP8 coding standard with flake8 and typing with mypy before_script: - flake8 . diff --git a/README.md b/README.md index 239c25a..b8fa639 100644 --- a/README.md +++ b/README.md @@ -291,13 +291,16 @@ Detailed logging of device register operations can be enabled with: ina = INA219(SHUNT_OHMS, log_level=logging.DEBUG) ``` -## Testing +## Development -Install test dependencies first _(recommended to use virtual environments)_: +Install development dependencies first _(recommended to use virtual environments)_. This includes +package dependencies, testing dependencies and static analysis dependencies. ```shell -pip3 install -r tests/requirements.txt +pip3 install -r requirements-dev.txt ``` +### Testing + ```shell python3 -m unittest discover -s tests -p 'test_*.py' ``` @@ -316,7 +319,13 @@ coverage report -m coverage xml ``` -## Coding Standard +### Coding Standard This library adheres to the _PEP8_ standard and follows the _idiomatic_ style described in the book _Writing Idiomatic Python_ by _Jeff Knupp_. + +To perform local linting and type checks, run: +```sh +flake8 . +mypy -p ina219 --strict +``` diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..e112dd2 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +-r ./requirements.txt +-r ./tests/requirements.txt + +flake8 +mypy diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4f673d5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Adafruit_GPIO==1.0.1 diff --git a/tests/requirements.txt b/tests/requirements.txt index 4d66aef..7980166 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,3 @@ -Adafruit_GPIO==1.0.1 mock==2.0.0 coverage==5.1 codecov>=2.1