[Pkg-bitcoin-commits] [python-quamash] 58/78: style
Jonas Smedegaard
dr at jones.dk
Tue Dec 19 01:19:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/0.6.0_dfsg-1
in repository python-quamash.
commit 65a40b12cd77cbe995ee7ab51303dfdb45cd492b
Author: Mark Thomas West Harviston <mark.harviston at gmail.com>
Date: Sun Nov 19 18:43:59 2017 -0800
style
---
.travis.yml | 2 +-
conftest.py | 12 ++++++------
quamash/__init__.py | 19 ++++++++-----------
tests/test_qeventloop.py | 10 ++++------
4 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 0d2f898..6fb1979 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -55,7 +55,7 @@ install:
# PySide
- if [ $TRAVIS_PYTHON_VERSION != '3.5' && $TRAVIS_PYTHON_VERSION != '3.6' ]; then pip install --find-links wheelhouse/ pyside; fi
# flake8 style checker
- - pip install flake8 pep8-naming flake8-debugger flake8-docstrings pytest-timeout
+ - pip install flake8 pep8-naming flake8-debugger flake8-docstrings pytest-timeout flake8-commas
script:
- flake8
- flake8 --select=D1 quamash/*.py
diff --git a/conftest.py b/conftest.py
index 22d3648..c1078d3 100644
--- a/conftest.py
+++ b/conftest.py
@@ -7,20 +7,20 @@ sys.path.insert(0, os.path.dirname(__file__))
try:
import colorlog
handler = colorlog.StreamHandler()
-
+
formatter = colorlog.ColoredFormatter(
"%(log_color)s%(levelname)-8s%(reset)s %(name)-32s %(message)s",
datefmt=None,
reset=True,
log_colors={
- 'DEBUG': 'cyan',
- 'INFO': 'green',
- 'WARNING': 'yellow',
- 'ERROR': 'red',
+ 'DEBUG': 'cyan',
+ 'INFO': 'green',
+ 'WARNING': 'yellow',
+ 'ERROR': 'red',
'CRITICAL': 'red,bg_white',
},
secondary_log_colors={},
- style='%'
+ style='%',
)
handler.setFormatter(formatter)
logger = colorlog.getLogger()
diff --git a/quamash/__init__.py b/quamash/__init__.py
index bda0cc0..6f3a404 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -78,7 +78,7 @@ class _QThreadWorker(QtCore.QThread):
future, callback, args, kwargs = command
self._logger.debug(
'#{} got callback {} with args {} and kwargs {} from queue'
- .format(self.__num, callback, args, kwargs)
+ .format(self.__num, callback, args, kwargs),
)
if future.set_running_or_notify_cancel():
self._logger.debug('Invoking callback')
@@ -178,25 +178,22 @@ else:
from . import _unix
_baseclass = _unix.baseclass
+
@with_logger
class _SimpleTimer(QtCore.QObject):
- #__slots__ = 'callback', 'timer_id', 'stopped'
def __init__(self):
super().__init__()
self.__callbacks = {}
self._stopped = False
def add_callback(self, handle, delay=0):
- #self._logger.debug('Adding callback {} with delay {}'.format(handle, delay))
- #timer = _SimpleTimer(delay * 1000, upon_timeout)
- #self.__timers.append(timer)
timerid = self.startTimer(delay * 1000)
self._logger.debug("Registering timer id {0}".format(timerid))
assert timerid not in self.__callbacks
self.__callbacks[timerid] = handle
return handle
- def timerEvent(self, event): # noqa
+ def timerEvent(self, event):
timerid = event.timerId()
self._logger.debug("Timer event on id {0}".format(timerid))
if self._stopped:
@@ -206,7 +203,7 @@ class _SimpleTimer(QtCore.QObject):
else:
try:
handle = self.__callbacks[timerid]
- except KeyError as e :
+ except KeyError as e:
self._logger.debug(str(e))
pass
else:
@@ -387,7 +384,7 @@ class QEventLoop(_baseclass):
self._logger.debug('Adding reader callback for file descriptor {}'.format(fd))
notifier.activated.connect(
lambda: self.__on_notifier_ready(
- self._read_notifiers, notifier, fd, callback, args)
+ self._read_notifiers, notifier, fd, callback, args) # noqa: C812
)
self._read_notifiers[fd] = notifier
@@ -423,7 +420,7 @@ class QEventLoop(_baseclass):
self._logger.debug('Adding writer callback for file descriptor {}'.format(fd))
notifier.activated.connect(
lambda: self.__on_notifier_ready(
- self._write_notifiers, notifier, fd, callback, args)
+ self._write_notifiers, notifier, fd, callback, args) # noqa: C812
)
self._write_notifiers[fd] = notifier
@@ -461,7 +458,7 @@ class QEventLoop(_baseclass):
if fd not in notifiers:
self._logger.warning(
'Socket notifier for fd {} is ready, even though it should be disabled, not calling {} and disabling'
- .format(fd, callback)
+ .format(fd, callback),
)
notifier.setEnabled(False)
return
@@ -596,5 +593,5 @@ class QEventLoop(_baseclass):
# In some cases, the error method itself fails, don't have a lot of options in that case
try:
cls._logger.error(*args, **kwds)
- except:
+ except: # noqa E722
sys.stderr.write('{!r}, {!r}\n'.format(args, kwds))
diff --git a/tests/test_qeventloop.py b/tests/test_qeventloop.py
index 53b775c..1417aaa 100644
--- a/tests/test_qeventloop.py
+++ b/tests/test_qeventloop.py
@@ -2,7 +2,6 @@
# © 2014 Arve Knudsen <arve.knudsen at gmail.com>
# BSD License
import asyncio
-import locale
import logging
import sys
import os
@@ -58,7 +57,7 @@ def loop(request, application):
@pytest.fixture(
- params=[None, quamash.QThreadExecutor, ThreadPoolExecutor, ProcessPoolExecutor]
+ params=[None, quamash.QThreadExecutor, ThreadPoolExecutor, ProcessPoolExecutor],
)
def executor(request):
exc_cls = request.param
@@ -169,12 +168,13 @@ def test_can_terminate_subprocess(loop):
@asyncio.coroutine
def mycoro():
process = yield from asyncio.create_subprocess_exec(
- sys.executable or 'python', '-c', 'import time\nwhile True: time.sleep(1)')
+ sys.executable or 'python', '-c', 'import time\nwhile True: time.sleep(1)')
process.terminate()
yield from process.wait()
assert process.returncode != 0
loop.run_until_complete(mycoro())
+
@pytest.mark.raises(ExceptionTester)
def test_loop_callback_exceptions_bubble_up(loop):
"""Verify that test exceptions raised in event loop callbacks bubble up."""
@@ -671,9 +671,7 @@ def test_scheduling(loop, sock_pair):
def writer_cb(fut):
if fut.done():
- cb_called.set_exception(
- ValueError("writer_cb called twice")
- )
+ cb_called.set_exception(ValueError("writer_cb called twice"))
fut.set_result(None)
def fut_cb(fut):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/python-quamash.git
More information about the Pkg-bitcoin-commits
mailing list