From 2d7e2ff8379c1171bdd6ae4113016ea601684d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Fri, 7 Feb 2020 22:58:04 +0100 Subject: [PATCH] static typing --- coolamqp/clustering/events.py | 2 +- coolamqp/clustering/single.py | 8 ++++++-- coolamqp/uplink/connection/connection.py | 2 +- coolamqp/uplink/listener/thread.py | 3 ++- setup.py | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/coolamqp/clustering/events.py b/coolamqp/clustering/events.py index 0e38942..872fdc4 100644 --- a/coolamqp/clustering/events.py +++ b/coolamqp/clustering/events.py @@ -41,7 +41,7 @@ class MessageReceived(ReceivedMessage, Event): Something that works as an ersatz ReceivedMessage, but is an event """ - def __init__(self, msg): + def __init__(self, msg): # type: (ReceivedMessage) -> None """:type msg: ReceivedMessage""" ReceivedMessage.__init__(self, msg.body, msg.exchange_name, msg.routing_key, diff --git a/coolamqp/clustering/single.py b/coolamqp/clustering/single.py index e66c35e..8922b39 100644 --- a/coolamqp/clustering/single.py +++ b/coolamqp/clustering/single.py @@ -14,8 +14,12 @@ class SingleNodeReconnector(object): Connection to one node. It will do it's best to remain alive. """ - def __init__(self, node_def, attache_group, listener_thread, extra_properties=None, - log_frames=None, name=None): + def __init__(self, node_def, # type: coolamqp.objects.NodeDefinition + attache_group, # type: coolamqp.attaches.AttacheGroup + listener_thread, # type: coolamqp.uplink.ListenerThread + extra_properties=None, # type: tp.Dict[bytes, tp.Tuple[tp.Any, str]] + log_frames=None, # type: tp.Callable[] + name=None): self.listener_thread = listener_thread self.node_def = node_def self.attache_group = attache_group diff --git a/coolamqp/uplink/connection/connection.py b/coolamqp/uplink/connection/connection.py index bb67d25..c5fec49 100644 --- a/coolamqp/uplink/connection/connection.py +++ b/coolamqp/uplink/connection/connection.py @@ -6,7 +6,7 @@ import logging import socket import time import uuid - +import typing as tp import monotonic from coolamqp.exceptions import ConnectionDead diff --git a/coolamqp/uplink/listener/thread.py b/coolamqp/uplink/listener/thread.py index 10ec8f8..c7e03a5 100644 --- a/coolamqp/uplink/listener/thread.py +++ b/coolamqp/uplink/listener/thread.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, division, print_function import threading +import typing as tp from coolamqp.objects import Callable from coolamqp.uplink.listener.epoll_listener import EpollListener @@ -14,7 +15,7 @@ class ListenerThread(threading.Thread): It automatically picks the best listener for given platform. """ - def __init__(self, name=None): + def __init__(self, name=None): # type: (tp.Optional[str]) -> None threading.Thread.__init__(self, name='coolamqp/ListenerThread') self.daemon = True self.name = name or 'CoolAMQP' diff --git a/setup.py b/setup.py index 3a2d024..e6a2d15 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup(keywords=['amqp', 'rabbitmq', 'client', 'network', 'ha', 'high availabilit Also, handles your reconnects and transactionality THE RIGHT WAY, though somewhat opinionated''', install_requires=['six', 'monotonic', 'futures', 'typing'], # per coverage version for codeclimate-reporter - tests_require=["nose2", 'coverage>=4.0,<4.4', "nose2[coverage_plugin]"], + tests_require=["nose2", "nose2[coverage_plugin]"], test_suite='nose2.collector.collector' ) -- GitLab