Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Fix LGTM.com alerts #646

Merged
merged 2 commits into from Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/646.misc
@@ -0,0 +1 @@
Fix LGTM.com alerts
8 changes: 3 additions & 5 deletions aioredis/abc.py
Expand Up @@ -5,8 +5,6 @@
import abc
import asyncio

from abc import ABC


__all__ = [
'AbcConnection',
Expand All @@ -15,7 +13,7 @@
]


class AbcConnection(ABC):
class AbcConnection(abc.ABC):
"""Abstract connection interface."""

@abc.abstractmethod
Expand Down Expand Up @@ -84,7 +82,7 @@ class AbcPool(AbcConnection):
"""

@abc.abstractmethod
def get_connection(self): # TODO: arguments
def get_connection(self, command, args=()):
"""
Gets free connection from pool in a sync way.

Expand All @@ -109,7 +107,7 @@ def address(self):
"""Connection address or None."""


class AbcChannel(ABC):
class AbcChannel(abc.ABC):
"""Abstract Pub/Sub Channel interface."""

@property
Expand Down
3 changes: 1 addition & 2 deletions aioredis/locks.py
Expand Up @@ -2,7 +2,6 @@
import sys

from asyncio.locks import Lock as _Lock
from asyncio import coroutine

# Fixes an issue with all Python versions that leaves pending waiters
# without being awakened when the first waiter is canceled.
Expand All @@ -14,7 +13,7 @@
class Lock(_Lock):

if sys.version_info < (3, 7, 0):
@coroutine
@asyncio.coroutine
def acquire(self):
"""Acquire a lock.
This method blocks until the lock is unlocked, then sets it to
Expand Down
3 changes: 1 addition & 2 deletions aioredis/pool.py
Expand Up @@ -282,8 +282,7 @@ async def select(self, db):
async with self._cond:
for i in range(self.freesize):
res = res and (await self._pool[i].select(db))
else:
self._db = db
self._db = db
return res

async def auth(self, password):
Expand Down
9 changes: 4 additions & 5 deletions aioredis/sentinel/pool.py
Expand Up @@ -83,7 +83,7 @@ def __init__(self, sentinels, *, db=None, password=None, ssl=None,
async def echo_events():
try:
while await monitor.wait_message():
ch, (ev, data) = await monitor.get(encoding='utf-8')
_, (ev, data) = await monitor.get(encoding='utf-8')
ev = ev.decode('utf-8')
_logger.debug("%s: %s", ev, data)
if ev in ('+odown',):
Expand Down Expand Up @@ -295,8 +295,8 @@ async def discover_master(self, service, timeout):
# TODO: clear (drop) connections to schedule reconnect
await asyncio.sleep(idle_timeout, loop=self._loop)
continue
else:
raise MasterNotFoundError("No master found for {}".format(service))
# Otherwise
raise MasterNotFoundError("No master found for {}".format(service))

async def discover_slave(self, service, timeout, **kwargs):
"""Perform Slave discovery for specified service."""
Expand Down Expand Up @@ -358,8 +358,7 @@ async def _get_slave_address(self, sentinel, service):
if {'s_down', 'o_down', 'disconnected'} & flags:
continue
return address
else:
raise BadState(state) # XXX: only last state
raise BadState() # XXX: only last state

async def _verify_service_role(self, conn, role):
res = await conn.execute(b'role', encoding='utf-8')
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -29,8 +29,7 @@ def read_version():
match = regexp.match(line)
if match is not None:
return match.group(1)
else:
raise RuntimeError('Cannot find version in aioredis/__init__.py')
raise RuntimeError('Cannot find version in {}'.format(init_py))


classifiers = [
Expand Down