Add pylint

This commit is contained in:
Otto Winter 2020-07-14 20:00:12 +02:00
parent d225cb305a
commit 8bf95336d6
No known key found for this signature in database
GPG Key ID: 48ED2DDB96D7682C
8 changed files with 65 additions and 6 deletions

22
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: CI
on:
push:
branches: [master]
pull_request:
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

View File

@ -5,9 +5,25 @@ on:
types: [published]
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:
name: Build and publish to PyPi
runs-on: ubuntu-latest
needs: [pylint]
steps:
- uses: actions/checkout@v2
- name: Set up Python

View File

@ -1,5 +1,5 @@
from .client import *
from .connection import *
from .core import *
from .client import APIClient
from .connection import ConnectionParams, APIConnection
from .core import APIConnectionError, MESSAGE_TYPE_TO_PROTO
from .model import *
from .util import *
from .util import resolve_ip_address_getaddrinfo, resolve_ip_address

View File

@ -166,6 +166,7 @@ class APIClient:
return
kwargs = {}
# pylint: disable=undefined-loop-variable
for key, _ in attr.fields_dict(cls).items():
kwargs[key] = getattr(msg, key)
on_state(cls(**kwargs))
@ -380,6 +381,7 @@ class APIClient:
UserServiceArgType.FLOAT_ARRAY: 'float_array',
UserServiceArgType.STRING_ARRAY: 'string_array',
}
# pylint: disable=redefined-outer-name
if arg_desc.type_ in map_array:
attr = getattr(arg, map_array[arg_desc.type_])
attr.extend(val)
@ -387,6 +389,7 @@ class APIClient:
setattr(arg, map_single[arg_desc.type_], val)
args.append(arg)
# pylint: disable=no-member
req.args.extend(args)
await self._connection.send_message(req)

View File

@ -146,7 +146,7 @@ class APIConnection:
resp.api_version_major, resp.api_version_minor)
if self._api_version.major > 2:
_LOGGER.error("%s: Incompatible version %s! Closing connection",
self._api_version.major)
self._params.address, self._api_version.major)
await self._on_error()
raise APIConnectionError("Incompatible API version.")
self._connected = True
@ -205,6 +205,7 @@ class APIConnection:
self._params.address, type(msg), str(msg))
req = bytes([0])
req += _varuint_to_bytes(len(encoded))
# pylint: disable=undefined-loop-variable
req += _varuint_to_bytes(message_type)
req += encoded
await self._write(req)
@ -313,7 +314,7 @@ class APIConnection:
self._params.address, err)
await self._on_error()
break
except Exception as err:
except Exception as err: # pylint: disable=broad-except
_LOGGER.info("%s: Unexpected error while reading incoming messages: %s",
self._params.address, err)
await self._on_error()

View File

@ -2,6 +2,7 @@ import asyncio
import socket
from typing import Optional, Tuple, Any
# pylint: disable=cyclic-import
from aioesphomeapi.core import APIConnectionError

15
pylintrc Normal file
View File

@ -0,0 +1,15 @@
[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,

1
requirements_test.txt Normal file
View File

@ -0,0 +1 @@
pylint==2.5.3