Skip to content

Commit

Permalink
Fix or suppress remaining pylint warnings
Browse files Browse the repository at this point in the history
- too-many-* messages were temporarily disabled, and should be
re-enabled sooner or later
- cyclic-import should be re-enabled when pylint-dev/pylint#3525 is fixed
  • Loading branch information
Parnassius committed Aug 23, 2020
1 parent 5ff545f commit 41d80c7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
27 changes: 14 additions & 13 deletions app.py
Expand Up @@ -9,22 +9,23 @@
from connection import CONNECTION
from server import SERVER

if __name__ == "__main__":
queue: SimpleQueue[str] = SimpleQueue()

def shutdown(
sig: signal.Signals, frame_type: FrameType, # pylint: disable=no-member
) -> None:
if CONNECTION.websocket is not None and CONNECTION.loop is not None:
for task in asyncio.all_tasks(loop=CONNECTION.loop):
task.cancel()
coro = CONNECTION.websocket.close()
asyncio.run_coroutine_threadsafe(coro, CONNECTION.loop)


def main() -> None:
queue: SimpleQueue[str] = SimpleQueue()
threading.Thread(target=SERVER.serve_forever, args=(queue,), daemon=True).start()
threading.Thread(target=CONNECTION.open_connection, args=(queue,)).start()

def shutdown(
sig: signal.Signals, frame_type: FrameType
) -> None: # pylint: disable=unused-argument
try:
if CONNECTION.websocket is not None and CONNECTION.loop is not None:
for task in asyncio.all_tasks(loop=CONNECTION.loop):
task.cancel()
coro = CONNECTION.websocket.close()
asyncio.run_coroutine_threadsafe(coro, CONNECTION.loop)
except: # lgtm [py/catch-base-exception]
pass

if __name__ == "__main__":
signal.signal(signal.SIGINT, shutdown)
main()
6 changes: 4 additions & 2 deletions connection.py
Expand Up @@ -74,8 +74,10 @@ async def start_websocket(self) -> None:
try:
async with websockets.connect(
self.url,
ping_interval=None, # type: ignore # should be fixed by https://github.com/aaugustin/websockets/commit/93ad88a9a8fe2ea8d96fb1d2a0f1625a3c5fee7c
max_size=None, # type: ignore # should be fixed by https://github.com/aaugustin/websockets/commit/93ad88a9a8fe2ea8d96fb1d2a0f1625a3c5fee7c
# these two should be fixed by the next websockets release
# https://github.com/aaugustin/websockets/commit/93ad88a9a8fe2ea8d96fb1d2a0f1625a3c5fee7c
ping_interval=None, # type: ignore
max_size=None, # type: ignore
) as websocket:
self.websocket = websocket
self.connection_start = time()
Expand Down
4 changes: 3 additions & 1 deletion plugins/repeats.py
Expand Up @@ -70,7 +70,9 @@ def __init__(
shift = self.delta * math.ceil(offline_period / self.delta)
self.offset += shift - offline_period

self.task: Optional[asyncio.Future[None]] = None
self.task: Optional[
asyncio.Future[None] # pylint: disable=unsubscriptable-object
] = None

log = [
"----- REPEAT -----",
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Expand Up @@ -5,6 +5,16 @@ disable = [
"missing-function-docstring",
"missing-module-docstring",
"unused-argument",

# temporarily disabled, should be re-enabled sooner or later
"too-many-arguments",
"too-many-branches",
"too-many-instance-attributes",
"too-many-locals",
"too-many-statements",

# disabled until https://github.com/PyCQA/pylint/issues/3525 is fixed
"cyclic-import",
]

[tool.pylint.format]
Expand Down

0 comments on commit 41d80c7

Please sign in to comment.