From dbbf87e42b340bfb0c9a9d0b2265415e88f6271f Mon Sep 17 00:00:00 2001 From: Dmitry Orlov Date: Sun, 2 Apr 2017 23:42:53 +0300 Subject: [PATCH] add pylama and fixes for linter --- .travis.yml | 1 - aio_pika/connection.py | 8 +++----- pylama.ini | 5 +++++ setup.py | 3 +++ tests/test_amqp.py | 15 +++++++-------- tox.ini | 21 +++++++-------------- 6 files changed, 25 insertions(+), 28 deletions(-) create mode 100644 pylama.ini diff --git a/.travis.yml b/.travis.yml index 520ced82..ae47d1df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ matrix: env: TOXENV=py35 - python: 3.6 env: TOXENV=py36 - install: - pip install tox coveralls script: diff --git a/aio_pika/connection.py b/aio_pika/connection.py index 8027b7a0..706ead1d 100644 --- a/aio_pika/connection.py +++ b/aio_pika/connection.py @@ -173,9 +173,9 @@ def close(self) -> None: @asyncio.coroutine def connect(url: str=None, *, host: str='localhost', - port: int=5672, login: str='guest', - password: str='guest', virtualhost: str='/', - ssl: bool=False, loop=None, **kwargs) -> Connection: + port: int=5672, login: str='guest', + password: str='guest', virtualhost: str='/', + ssl: bool=False, loop=None, **kwargs) -> Connection: """ Make connection to the broker :param url: `RFC3986`_ formatted broker address. When :class:`None` will be used keyword arguments. @@ -220,5 +220,3 @@ def connect_url(url: str, loop=None) -> Connection: __all__ = ('connect', 'connect_url', 'Connection') - - diff --git a/pylama.ini b/pylama.ini new file mode 100644 index 00000000..7798fd6d --- /dev/null +++ b/pylama.ini @@ -0,0 +1,5 @@ +[pylama] +ignore=E402,W0401,E712,E722,C901,E0603,E711 + +[pylama:pycodestyle] +max_line_length = 120 \ No newline at end of file diff --git a/setup.py b/setup.py index f1c29375..81e9bb89 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,8 @@ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: Implementation :: PyPy', 'Programming Language :: Python :: Implementation :: CPython', ], packages=find_packages(exclude=['tests']), @@ -48,6 +50,7 @@ 'asynctest', 'coverage!=4.3', 'coveralls', + 'pylama', 'pytest', 'pytest-asyncio', 'pytest-cov', diff --git a/tests/test_amqp.py b/tests/test_amqp.py index 23ee88b3..79451021 100644 --- a/tests/test_amqp.py +++ b/tests/test_amqp.py @@ -4,7 +4,7 @@ import pytest import shortuuid import aio_pika.exceptions -from aio_pika import connect, connect_url, Message, Connection, Channel, Exchange +from aio_pika import connect, connect_url, Message from aio_pika.exceptions import ProbableAuthenticationError, MessageProcessError from aio_pika.exchange import ExchangeType from aio_pika.tools import wait @@ -32,8 +32,8 @@ def test_connection_url_deprecated(self): def test_channel_close(self): client = yield from connect(AMQP_URL, loop=self.loop) - queue_name = self.get_random_name("test_connection") - routing_key = self.get_random_name() + self.get_random_name("test_connection") + self.get_random_name() self.__closed = False @@ -127,12 +127,12 @@ def test_context_process(self): incoming_message = yield from queue.get(timeout=5) with self.assertRaises(AssertionError): - with incoming_message.proccess(requeue=True) as msg: + with incoming_message.proccess(requeue=True): raise AssertionError incoming_message = yield from queue.get(timeout=5) - with incoming_message.proccess() as msg: + with incoming_message.proccess(): pass self.assertEqual(incoming_message.body, body) @@ -208,7 +208,6 @@ def test_reject_twice(self): yield from queue.delete() yield from wait((client.close(), client.closing), loop=self.loop) - @pytest.mark.asyncio def test_consuming(self): client = yield from connect(AMQP_URL, loop=self.loop) @@ -417,7 +416,7 @@ def test_exchange_delete(self): @pytest.mark.asyncio def test_dlx(self): - client = yield from connect(AMQP_URL, loop=self.loop) # type: Connection + client = yield from connect(AMQP_URL, loop=self.loop) direct_queue_name = self.get_random_name("test_dlx", "direct") dlx_queue_name = self.get_random_name("test_dlx", "dlx") @@ -483,7 +482,7 @@ def test_connection_close(self): routing_key = self.get_random_name() channel = yield from client.channel() # type: Channel - exchange = yield from channel.declare_exchange('direct', auto_delete=True) # type: Exchange + exchange = yield from channel.declare_exchange('direct', auto_delete=True) try: with self.assertRaises(aio_pika.exceptions.ChannelClosed): diff --git a/tox.ini b/tox.ini index edfa0087..c51bb4fd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{4,5,6},qa +envlist = py3{4,5,6} [testenv] setenv = @@ -11,17 +11,10 @@ extras = develop commands= - py.test --cov aio_pika --cov-report=term-missing tests + py.test \ + --cov aio_pika \ + --cov-report=term-missing \ + --pylama aio_pika \ + --pylama tests \ + tests coveralls - - -[testenv:qa] -basepython = python3.5 - -skip_install = True - -deps = - coala-bears>=0.9 - -commands = - coala --non-interactive