Refactor Lint Configs (#53)
This commit is contained in:
parent
2629e8d86c
commit
f11f6e0122
|
@ -6,80 +6,60 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pylint:
|
ci:
|
||||||
|
name: ${{ matrix.name }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- id: flake8
|
||||||
|
name: Lint with flake8
|
||||||
|
- id: pylint
|
||||||
|
name: Lint with pylint
|
||||||
|
- id: black
|
||||||
|
name: Check formatting with black
|
||||||
|
- id: isort
|
||||||
|
name: Check import order with isort
|
||||||
|
- id: mypy
|
||||||
|
name: Check typing with mypy
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
with:
|
with:
|
||||||
python-version: '3.7'
|
python-version: '3.7'
|
||||||
- name: Set up Python environment
|
|
||||||
|
- name: Get pip cache dir
|
||||||
|
id: pip-cache
|
||||||
run: |
|
run: |
|
||||||
pip3 install -e .
|
echo "::set-output name=dir::$(pip cache dir)"
|
||||||
pip3 install -r requirements_test.txt
|
- name: Restore PIP cache
|
||||||
- name: Register problem matcher
|
uses: actions/cache@v2
|
||||||
run: |
|
|
||||||
echo "::add-matcher::.github/workflows/matchers/pylint.json"
|
|
||||||
- run: pylint aioesphomeapi
|
|
||||||
flake8:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
with:
|
||||||
python-version: '3.7'
|
path: ${{ steps.pip-cache.outputs.dir }}
|
||||||
|
key: pip-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt', 'requirements_test.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
pip-${{ steps.python.outputs.python-version }}-
|
||||||
- name: Set up Python environment
|
- name: Set up Python environment
|
||||||
run: |
|
run: |
|
||||||
|
pip3 install -r requirements.txt -r requirements_test.txt
|
||||||
pip3 install -e .
|
pip3 install -e .
|
||||||
pip3 install -r requirements_test.txt
|
|
||||||
- name: Register problem matcher
|
- name: Register problem matchers
|
||||||
run: |
|
run: |
|
||||||
echo "::add-matcher::.github/workflows/matchers/flake8.json"
|
echo "::add-matcher::.github/workflows/matchers/flake8.json"
|
||||||
- run: flake8 aioesphomeapi
|
echo "::add-matcher::.github/workflows/matchers/pylint.json"
|
||||||
black:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: '3.7'
|
|
||||||
- name: Set up Python environment
|
|
||||||
run: |
|
|
||||||
pip3 install -e .
|
|
||||||
pip3 install -r requirements_test.txt
|
|
||||||
- run: black --safe --exclude 'api_pb2.py|api_options_pb2.py' aioesphomeapi
|
|
||||||
isort:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: '3.7'
|
|
||||||
- name: Set up Python environment
|
|
||||||
run: |
|
|
||||||
pip3 install -e .
|
|
||||||
pip3 install -r requirements_test.txt
|
|
||||||
- name: Register problem matcher
|
|
||||||
run: |
|
|
||||||
echo "::add-matcher::.github/workflows/matchers/isort.json"
|
echo "::add-matcher::.github/workflows/matchers/isort.json"
|
||||||
- run: isort --check aioesphomeapi
|
|
||||||
mypy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: '3.7'
|
|
||||||
- name: Set up Python environment
|
|
||||||
run: |
|
|
||||||
pip3 install -e .
|
|
||||||
pip3 install -r requirements_test.txt
|
|
||||||
- name: Register problem matcher
|
|
||||||
run: |
|
|
||||||
echo "::add-matcher::.github/workflows/matchers/mypy.json"
|
echo "::add-matcher::.github/workflows/matchers/mypy.json"
|
||||||
- run: mypy --strict aioesphomeapi
|
|
||||||
|
- run: flake8 aioesphomeapi
|
||||||
|
if: ${{ matrix.id == 'flake8' }}
|
||||||
|
- run: pylint aioesphomeapi
|
||||||
|
if: ${{ matrix.id == 'pylint' }}
|
||||||
|
- run: black --check --diff --color aioesphomeapi
|
||||||
|
if: ${{ matrix.id == 'black' }}
|
||||||
|
- run: isort --check --diff aioesphomeapi
|
||||||
|
if: ${{ matrix.id == 'isort' }}
|
||||||
|
- run: mypy aioesphomeapi
|
||||||
|
if: ${{ matrix.id == 'mypy' }}
|
||||||
|
|
|
@ -5,25 +5,9 @@ on:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pylint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: '3.7'
|
|
||||||
- name: Set up Python environment
|
|
||||||
run: |
|
|
||||||
pip3 install -e .
|
|
||||||
pip3 install -r requirements_test.txt
|
|
||||||
|
|
||||||
- run: pylint aioesphomeapi
|
|
||||||
|
|
||||||
deploy-pypi:
|
deploy-pypi:
|
||||||
name: Build and publish to PyPi
|
name: Build and publish to PyPi
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [pylint]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
[mypy]
|
||||||
|
python_version = 3.7
|
||||||
|
show_error_codes = true
|
||||||
|
|
||||||
|
strict = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
18
pylintrc
18
pylintrc
|
@ -1,18 +0,0 @@
|
||||||
[MASTER]
|
|
||||||
reports=no
|
|
||||||
ignore=api_pb2.py,api_options_pb2.py
|
|
||||||
|
|
||||||
disable=
|
|
||||||
missing-docstring,
|
|
||||||
too-few-public-methods,
|
|
||||||
too-many-instance-attributes,
|
|
||||||
wildcard-import,
|
|
||||||
invalid-name,
|
|
||||||
too-many-arguments,
|
|
||||||
line-too-long,
|
|
||||||
protected-access,
|
|
||||||
unused-wildcard-import,
|
|
||||||
import-outside-toplevel,
|
|
||||||
raise-missing-from,
|
|
||||||
bad-mcs-classmethod-argument,
|
|
||||||
duplicate-code,
|
|
|
@ -2,3 +2,29 @@
|
||||||
profile = "black"
|
profile = "black"
|
||||||
multi_line_output = 3
|
multi_line_output = 3
|
||||||
extend_skip = ["api_pb2.py", "api_options_pb2.py"]
|
extend_skip = ["api_pb2.py", "api_options_pb2.py"]
|
||||||
|
|
||||||
|
[tool.black]
|
||||||
|
exclude = 'api_pb2.py|api_options_pb2.py'
|
||||||
|
target-version = ['py37']
|
||||||
|
|
||||||
|
[tool.pylint.MASTER]
|
||||||
|
reports = 'no'
|
||||||
|
ignore = [
|
||||||
|
"api_pb2.py",
|
||||||
|
"api_options_pb2.py"
|
||||||
|
]
|
||||||
|
disable = [
|
||||||
|
"missing-docstring",
|
||||||
|
"too-few-public-methods",
|
||||||
|
"too-many-instance-attributes",
|
||||||
|
"wildcard-import",
|
||||||
|
"invalid-name",
|
||||||
|
"too-many-arguments",
|
||||||
|
"line-too-long",
|
||||||
|
"protected-access",
|
||||||
|
"unused-wildcard-import",
|
||||||
|
"import-outside-toplevel",
|
||||||
|
"raise-missing-from",
|
||||||
|
"bad-mcs-classmethod-argument",
|
||||||
|
"duplicate-code",
|
||||||
|
]
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
black --safe --exclude 'api_pb2.py|api_options_pb2.py' aioesphomeapi
|
black --safe aioesphomeapi
|
||||||
pylint aioesphomeapi
|
pylint aioesphomeapi
|
||||||
flake8 aioesphomeapi
|
flake8 aioesphomeapi
|
||||||
isort aioesphomeapi
|
isort aioesphomeapi
|
||||||
mypy --strict aioesphomeapi
|
mypy aioesphomeapi
|
||||||
|
|
Loading…
Reference in New Issue