mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-11-22 12:05:12 +01:00
Add pylint
This commit is contained in:
parent
d225cb305a
commit
8bf95336d6
22
.github/workflows/ci.yml
vendored
Normal file
22
.github/workflows/ci.yml
vendored
Normal 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
|
16
.github/workflows/release.yml
vendored
16
.github/workflows/release.yml
vendored
@ -5,9 +5,25 @@ 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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from .client import *
|
from .client import APIClient
|
||||||
from .connection import *
|
from .connection import ConnectionParams, APIConnection
|
||||||
from .core import *
|
from .core import APIConnectionError, MESSAGE_TYPE_TO_PROTO
|
||||||
from .model import *
|
from .model import *
|
||||||
from .util import *
|
from .util import resolve_ip_address_getaddrinfo, resolve_ip_address
|
||||||
|
@ -166,6 +166,7 @@ class APIClient:
|
|||||||
return
|
return
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
# pylint: disable=undefined-loop-variable
|
||||||
for key, _ in attr.fields_dict(cls).items():
|
for key, _ in attr.fields_dict(cls).items():
|
||||||
kwargs[key] = getattr(msg, key)
|
kwargs[key] = getattr(msg, key)
|
||||||
on_state(cls(**kwargs))
|
on_state(cls(**kwargs))
|
||||||
@ -380,6 +381,7 @@ class APIClient:
|
|||||||
UserServiceArgType.FLOAT_ARRAY: 'float_array',
|
UserServiceArgType.FLOAT_ARRAY: 'float_array',
|
||||||
UserServiceArgType.STRING_ARRAY: 'string_array',
|
UserServiceArgType.STRING_ARRAY: 'string_array',
|
||||||
}
|
}
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
if arg_desc.type_ in map_array:
|
if arg_desc.type_ in map_array:
|
||||||
attr = getattr(arg, map_array[arg_desc.type_])
|
attr = getattr(arg, map_array[arg_desc.type_])
|
||||||
attr.extend(val)
|
attr.extend(val)
|
||||||
@ -387,6 +389,7 @@ class APIClient:
|
|||||||
setattr(arg, map_single[arg_desc.type_], val)
|
setattr(arg, map_single[arg_desc.type_], val)
|
||||||
|
|
||||||
args.append(arg)
|
args.append(arg)
|
||||||
|
# pylint: disable=no-member
|
||||||
req.args.extend(args)
|
req.args.extend(args)
|
||||||
await self._connection.send_message(req)
|
await self._connection.send_message(req)
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class APIConnection:
|
|||||||
resp.api_version_major, resp.api_version_minor)
|
resp.api_version_major, resp.api_version_minor)
|
||||||
if self._api_version.major > 2:
|
if self._api_version.major > 2:
|
||||||
_LOGGER.error("%s: Incompatible version %s! Closing connection",
|
_LOGGER.error("%s: Incompatible version %s! Closing connection",
|
||||||
self._api_version.major)
|
self._params.address, self._api_version.major)
|
||||||
await self._on_error()
|
await self._on_error()
|
||||||
raise APIConnectionError("Incompatible API version.")
|
raise APIConnectionError("Incompatible API version.")
|
||||||
self._connected = True
|
self._connected = True
|
||||||
@ -205,6 +205,7 @@ class APIConnection:
|
|||||||
self._params.address, type(msg), str(msg))
|
self._params.address, type(msg), str(msg))
|
||||||
req = bytes([0])
|
req = bytes([0])
|
||||||
req += _varuint_to_bytes(len(encoded))
|
req += _varuint_to_bytes(len(encoded))
|
||||||
|
# pylint: disable=undefined-loop-variable
|
||||||
req += _varuint_to_bytes(message_type)
|
req += _varuint_to_bytes(message_type)
|
||||||
req += encoded
|
req += encoded
|
||||||
await self._write(req)
|
await self._write(req)
|
||||||
@ -313,7 +314,7 @@ class APIConnection:
|
|||||||
self._params.address, err)
|
self._params.address, err)
|
||||||
await self._on_error()
|
await self._on_error()
|
||||||
break
|
break
|
||||||
except Exception as err:
|
except Exception as err: # pylint: disable=broad-except
|
||||||
_LOGGER.info("%s: Unexpected error while reading incoming messages: %s",
|
_LOGGER.info("%s: Unexpected error while reading incoming messages: %s",
|
||||||
self._params.address, err)
|
self._params.address, err)
|
||||||
await self._on_error()
|
await self._on_error()
|
||||||
|
@ -2,6 +2,7 @@ import asyncio
|
|||||||
import socket
|
import socket
|
||||||
from typing import Optional, Tuple, Any
|
from typing import Optional, Tuple, Any
|
||||||
|
|
||||||
|
# pylint: disable=cyclic-import
|
||||||
from aioesphomeapi.core import APIConnectionError
|
from aioesphomeapi.core import APIConnectionError
|
||||||
|
|
||||||
|
|
||||||
|
15
pylintrc
Normal file
15
pylintrc
Normal 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
1
requirements_test.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
pylint==2.5.3
|
Loading…
Reference in New Issue
Block a user