Skip to content

Commit

Permalink
Support type checking (#4)
Browse files Browse the repository at this point in the history
* pycodestyle -> flake8; + pytest-cov,mock,mypy

* mypy needs Py3.6 (PEP526+484)

* Config flake8, yapf, mypy

* Config pytest and coverage

* Settings for VSCode

* Full compliance with flake8 and mypy

* Document changes for mypy, flake8, pytest-mock/cov

* Replace pycodestyle with flake8 in GH actions

* Drop 3.6 in Windows GH Actions

* Update actions/setup-python to v2

See actions/setup-python#333

* Install pipenv manually (no more actions)

* Run flake8 and mypy in GH actions

* Check current dir with mypy
  • Loading branch information
ginolatorilla committed Feb 22, 2022
1 parent 2410814 commit 1a2f421
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 127 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/python-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ on:
- main
jobs:
style-check:
name: Check PEP8 compliance on Python ${{matrix.python-version}}
name: Check PEP8 and PEP484 compliance on Python ${{matrix.python-version}}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python-version}}
- uses: dschep/install-pipenv-action@v1
- name: Install PipEnv
run: pip install pipenv
- name: Install development packages with pipenv
run: ./bootstrap.py
- name: Lint with pycodestyle
- name: Lint with flake8 and mypy
run: |
pipenv run pycodestyle
pipenv run flake8
pipenv run mypy .
test:
name: Test on Python ${{matrix.python-version}} with PyTest
Expand All @@ -36,10 +38,11 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python-version}}
- uses: dschep/install-pipenv-action@v1
- name: Install PipEnv
run: pip install pipenv
- name: Install development packages with pipenv
run: ./bootstrap.py
- name: Test with pytest
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/python-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@ on:

jobs:
style-check:
name: Check PEP8 compliance on Python ${{matrix.python-version}}
name: Check PEP8 and PEP484 compliance on Python ${{matrix.python-version}}
runs-on: macos-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python-version}}
- uses: dschep/install-pipenv-action@v1
- name: Install PipEnv
run: pip install pipenv
- name: Install development packages with pipenv
run: ./bootstrap.py
- name: Lint with pycodestyle
- name: Lint with flake8 and mypy
run: |
pipenv run pycodestyle
pipenv run flake8
pipenv run mypy .
test:
name: Test on Python ${{matrix.python-version}} with PyTest
Expand All @@ -37,10 +39,11 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python-version}}
- uses: dschep/install-pipenv-action@v1
- name: Install PipEnv
run: pip install pipenv
- name: Install development packages with pipenv
run: ./bootstrap.py
- name: Test with pytest
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/python-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,40 @@ defaults:

jobs:
style-check:
name: Check PEP8 compliance on Python ${{matrix.python-version}}
name: Check PEP8 and PEP484 compliance on Python ${{matrix.python-version}}
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python-version}}
- uses: dschep/install-pipenv-action@v1
- name: Install PipEnv
run: pip install pipenv
- name: Install development packages with pipenv
run: python ./bootstrap.py
- name: Lint with pycodestyle
- name: Lint with flake8 and mypy
run: |
pipenv run pycodestyle
pipenv run flake8
pipenv run mypy .
test:
name: Test on Python ${{matrix.python-version}} with PyTest
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python-version}}
- uses: dschep/install-pipenv-action@v1
- name: Install PipEnv
run: pip install pipenv
- name: Install development packages with pipenv
run: |
python ./bootstrap.py
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.venv
.vscode
**/__pycache__
*.egg-info
reqlib-metadata
.coverage
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"python.formatting.provider": "yapf",
"python.linting.mypyEnabled": true,
"python.linting.flake8Enabled": true,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"--no-cov"
]
}
9 changes: 6 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ verify_ssl = true

[dev-packages]
pytest = "*"
pycodestyle = "*"
yapf = "*"
yourproject = {editable = true, extras = ["pretty"], path = "."}
yourproject = {editable = true, path = "."}
pytest-cov = "*"
pytest-mock = "*"
mypy = "*"
flake8 = "*"

[packages]

[requires]
python_version = "3"
python_version = "3.6"

0 comments on commit 1a2f421

Please sign in to comment.