8000 Clean up all flake8 errors. No code changes. · wulczer/txpostgres@8c14bf4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c14bf4

Browse files
committed
Clean up all flake8 errors. No code changes.
1 parent caf045e commit 8c14bf4

File tree

7 files changed

+87
-76
lines changed

7 files changed

+87
-76
lines changed

doc/cursor_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
conn = txpostgres.Connection()
1212
d = conn.connect('dbname=postgres')
1313

14+
1415
def useCursor(cur):
1516
# execute a query
1617
d = cur.execute(query)

doc/transaction_example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
conn = txpostgres.Connection()
88
d = conn.connect('dbname=postgres')
99

10-
# define a callable that will execute inside a transaction
10+
1111
def interaction(cur):
12+
"""
13+
A callable that will execute inside a transaction.
14+
"""
1215
# the parameter is a txpostgres Cursor
1316
d = cur.execute('create table test(x integer)')
1417
d.addCallback(lambda _: cur.execute('insert into test values (%s)', (1, )))

setup.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,22 @@
3333
description="Twisted wrapper for asynchronous PostgreSQL connections",
3434
long_description=__doc__,
3535
classifiers=[
36-
"Development Status :: 4 - Beta",
37-
"Environment :: Console",
38-
"Framework :: Twisted",
39-
"Intended Audience :: Developers",
40-
"Intended Audience :: End Users/Desktop",
41-
"License :: OSI Approved :: MIT License",
42-
"Operating System :: OS Independent",
43-
"Programming Language :: Python",
44-
"Topic :: Database",
45-
"Topic :: Software Development :: Libraries :: Python Modules",
46-
],
36+
"Development Status :: 4 - Beta",
37+
"Environment :: Console",
38+
"Framework :: Twisted",
39+
"Intended Audience :: Developers",
40+
"Intended Audience :: End Users/Desktop",
41+
"License :: OSI Approved :: MIT License",
42+
"Operating System :: OS Independent",
43+
"Programming Language :: Python",
44+
"Topic :: Database",
45+
"Topic :: Software Development :: Libraries :: Python Modules",
46+
],
4747
platforms=["any"],
4848
license="MIT",
4949
author="Jan Urbanski",
5050
maintainer="Jan Urbanski",
5151
author_email="wulczer@wulczer.org",
5252
maintainer_email="wulczer@wulczer.org",
5353
url="http://wulczer.org/",
54-
# package_dir={'': 'lib'},
5554
packages=["txpostgres"])

test/test_txpostgres.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ def test_connectionLostWhileReading(self):
219219
* a NOTIFY comes through and doRead is triggered
220220
* not all data is read from the socket and it remains readable
221221
* the connection is closed and the Deferred returned from poll()
222-
called inside doRead is errbacked without 58E8 being ever available to user
223-
code
222+
called inside doRead is errbacked without being ever available to
223+
user code
224224
225225
It has been reported that under heavy load this can happen.
226226
"""
@@ -317,14 +317,14 @@ def test_multipleConnections(self):
317317
host=DB_HOST, database=DB_NAME)
318318

319319
d.addCallback(lambda c: conn.connect(
320-
user=DB_USER, password=DB_PASS,
321-
host=DB_HOST, database=DB_NAME))
320+
user=DB_USER, password=DB_PASS,
321+
host=DB_HOST, database=DB_NAME))
322322
d = self.failUnlessFailure(d, txpostgres.AlreadyConnected)
323323

324324
d.addCallback(lambda _: conn.close())
325325
d.addCallback(lambda _: conn.connect(
326-
user=DB_USER, password=DB_PASS,
327-
host=DB_HOST, database=DB_NAME))
326+
user=DB_USER, password=DB_PASS,
327+
host=DB_HOST, database=DB_NAME))
328328
return d.addCallback(lambda c: c.close())
329329

330330
def test_errors(self):
@@ -603,11 +603,11 @@ def test_runOperation(self):
603603
d.addCallback(self.assertEquals, [(0, )])
604604

605605
d.addCallback(lambda _: self.conn.runOperation(
606-
"insert into simple values (%s)", (1, )))
606+
"insert into simple values (%s)", (1, )))
607607
d.addCallback(self.assertIdentical, None)
608608

609609
d.addCallback(lambda _: self.conn.runQuery(
610-
"select count(*) from simple"))
610+
"select count(*) from simple"))
611611
return d.addCallback(self.assertEquals, [(1, )])
612612

613613
def test_runSimpleInteraction(self):
@@ -629,7 +629,7 @@ def interaction(c, arg1, kwarg1):
629629
d.addCallback(self.assertEquals, "interaction done")
630630

631631
d.addCallback(lambda _: self.conn.runQuery(
632-
"select * from simple order by x"))
632+
"select * from simple order by x"))
633633
return d.addCallback(self.assertEquals, [(1, ), (2, )])
634634

635635
def test_runErrorInteraction(self):
@@ -646,7 +646,7 @@ def interaction(c):
646646
d = self.assertFailure(d, psycopg2.ProgrammingError)
647647

648648
d.addCallback(lambda _: self.conn.runQuery(
649-
"select count(*) from simple"))
649+
"select count(*) from simple"))
650650
return d.addCallback(self.assertEquals, [(0, )])
651651

652652
def test_errorOnRollback(self):
@@ -708,7 +708,7 @@ def test_terminatedConnection(self):
708708
# added correct terminated connection handling. Then only way to know
709709
# that seems to be looking at the __version__ string.
710710
if (getattr(psycopg2, '_impl', None) and
711-
'ctypes' not in psycopg2.__version__):
711+
'ctypes' not in psycopg2.__version__):
712712
raise unittest.SkipTest(
713713
"This test fails on versions of psycopg2ct 0.3 and older, "
714714
"which have a bug in terminated connection handling")
@@ -897,14 +897,14 @@ def test_operation(self):
897897
d = self.pool.runOperation("create table x (i int)")
898898
# give is a workout, 20 x the number of connections
899899
d.addCallback(lambda _: defer.gatherResults(
900-
[self.pool.runOperation("insert into x values (%s)", (i, ))
901-
for i in range(self.pool.min * 20)]))
900+
[self.pool.runOperation("insert into x values (%s)", (i, ))
901+
for i in range(self.pool.min * 20)]))
902902
d.addCallback(lambda _: self.pool.runQuery(
903-
"select * from x order by i"))
903+
"select * from x order by i"))
904904
d.addCallback(self.assertEquals, [(i, ) for i in
905-
range(self.pool.min * 20)])
905+
range(self.pool.min * 20)])
906906
return d.addCallback(lambda _: self.pool.runOperation(
907-
"drop table x"))
907+
"drop table x"))
908908

909909
def test_interaction(self):
910910
"""
@@ -998,7 +998,7 @@ def checkErrorAndHotswap(f):
998998
d.addErrback(checkErrorAndHotswap)
999999

10001000
d.addCallback(lambda _: defer.gatherResults([
1001-
pool.runQuery("select 1") for _ in range(3)]))
1001+
pool.runQuery("select 1") for __ in range(3)]))
10021002
d.addCallback(self.assertEquals, [[(1, )]] * 3)
10031003
return d.addCallback(lambda _: pool.close())
10041004

@@ -1111,7 +1111,7 @@ def cancelQuery(_):
11111111
d = self.conn.runInteraction(interaction)
11121112
d = self.failUnlessFailure(d, defer.CancelledError)
11131113
d.addCallback(lambda _: 10000 self.conn.runQuery(
1114-
"select * from simple"))
1114+
"select * from simple"))
11151115
return d.addCallback(self.assertEquals, [])
11161116

11171117
def test_cancelMultipleQueries(self):
@@ -1158,6 +1158,7 @@ def test_removeNonexistentObserver(self):
11581158

11591159
def observer1(notify):
11601160
pass
1161+
11611162
def observer2(notify):
11621163
pass
11631164

@@ -1210,11 +1211,12 @@ def observer(notify):
12101211
d.addCallback(lambda _: notifyD)
12111212
d.addCallback(lambda _: self.assertEquals(len(self.notifies), 1))
12121213
return d.addCallback(lambda _: self.assertEquals(
1213-
self.notifies[0][1], "txpostgres_test"))
1214+
self.notifies[0][1], "txpostgres_test"))
12141215

12151216
def test_simpleNotifySameConnection(self):
12161217
"""
1217-
Notifications sent from the listening session are delivered to the session.
1218+
Notifications sent from the listening session are delivered to the
1219+
session.
12181220
"""
12191221
notifyD = defer.Deferred()
12201222

@@ -1230,7 +1232,7 @@ def observer(notify):
12301232
d.addCallback(lambda _: notifyD)
12311233
d.addCallback(lambda _: self.assertEquals(len(self.notifies), 1))
12321234
return d.addCallback(lambda _: self.assertEquals(
1233-
self.notifies[0][1], "txpostgres_test"))
1235+
self.notifies[0][1], "txpostgres_test"))
12341236

12351237
def test_listenUnlisten(self):
12361238
"""
@@ -1249,13 +1251,13 @@ def observer(notify):
12491251
d.addCallback(lambda _: notifyD)
12501252
d.addCallback(lambda _: self.assertEquals(len(self.notifies), 1))
12511253
d.addCallback(lambda _: self.conn.runOperation(
1252-
"unlisten txpostgres_test"))
1254+
"unlisten txpostgres_test"))
12531255
d.addCallback(lambda _: self.sendNotify())
12541256
# run a query to force the reactor to spin and flush eventual pending
12551257
# notifications, which there should be none since we did unlisten
12561258
d.addCallback(lambda _: self.conn.runOperation("select 1"))
12571259
return d.addCallback(lambda _: self.assertEquals(
1258-
len(self.notifies), 1))
1260+
len(self.notifies), 1))
12591261

12601262
def test_multipleNotifies(self):
12611263
"""
@@ -1276,7 +1278,7 @@ def observer(notify):
12761278
d.addCallback(lambda _: self.sendNotify())
12771279
d.addCallback(lambda _ C94A : notifyD)
12781280
return d.addCallback(lambda _: self.assertEquals(
1279-
len(self.notifies), 3))
1281+
len(self.notifies), 3))
12801282

12811283
def test_notifyDeliveryOrder(self):
12821284
"""
@@ -1313,7 +1315,7 @@ def observer(notify):
13131315
d.addCallback(lambda _: notifyD)
13141316
# check that they were processed in the right order
13151317
return d.addCallback(lambda _: self.assertEquals(
1316-
[n.payload for n in self.notifies], payloads))
1318+
[n.payload for n in self.notifies], payloads))
13171319

13181320
def test_multipleObservers(self):
13191321
"""
@@ -1342,7 +1344,7 @@ def observer2(notify):
13421344
d.addCallback(lambda _: firstNotifyD)
13431345
# the order is not determined though
13441346
d.addCallback(lambda _: self.assertEquals(
1345-
set(self.notifies), set([1, 2])))
1347+
set(self.notifies), set([1, 2])))
13461348
d.addCallback(lambda _: self.conn.removeNotifyObserver(observer2))
13471349
d.addCallback(lambda _: self.sendNotify())
13481350
d.addCallback(lambda _: secondNotifyD)
@@ -1380,9 +1382,9 @@ def observer2(notify):
13801382
d.addCallback(lambda _: self.sendNotify())
13811383
d.addCallback(lambda _: notifyD)
13821384
d.addCallback(lambda _: self.assertEquals(
1383-
len(self.flushLoggedErrors(RuntimeError)), 1))
1385+
len(self.flushLoggedErrors(RuntimeError)), 1))
13841386
return d.addCallback(lambda _: self.assertEquals(
1385-
self.notifies, [1, 1]))
1387+
self.notifies, [1, 1]))
13861388

13871389
def test_observerReturnsDeferred(self):
13881390
"""
@@ -1424,7 +1426,7 @@ def makeObserver(observerD, notifyD):
14241426
d.addCallback(lambda _: fireAllObserverDs())
14251427
# both observers should now be called
14261428
return d.addCallback(lambda _: self.assertEquals(
1427-
len(self.notifies), 2))
1429+
len(self.notifies), 2))
14281430

14291431
def test_observerReturnsFailingDeferred(self):
14301432
"""
@@ -1455,9 +1457,9 @@ def observer(notify):
14551457
d.addCallback(lambda _: notifyD)
14561458
# both errors get logged
14571459
d.addCallback(lambda _: self.assertEquals(
1458-
len(self.flushLoggedErrors(RuntimeError)), 2))
1460+
len(self.flushLoggedErrors(RuntimeError)), 2))
14591461
return d.addCallback(lambda _: self.assertEquals(
1460-
self.notifies, [1, 1]))
1462+
self.notifies, [1, 1]))
14611463

14621464
def test_customNotifyCooperator(self):
14631465
"""
@@ -1490,7 +1492,7 @@ def observer(notify):
14901492
d.addCallback(lambda _: self.sendNotify())
14911493
d.addCallback(lambda _: cooperateD)
14921494
d.addCallback(lambda _: self.assertEquals(
1493-
cooperator.result, [True]))
1495+
cooperator.result, [True]))
14941496
return d.addCallback(lambda _: c.close())
14951497

14961498

txpostgres/reconnection.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ def __init__(self, deathChecker=None,
8888
used.
8989
:type reconnectionIterator: callable
9090
91-
:param reactor: A Twisted reactor or :class:`None`, which means the current
92-
reactor.
91+
:param reactor: A Twisted reactor or :class:`None`, which means
92+
the current reactor.
9393
"""
9494
self.deathChecker = deathChecker or defaultDeathChecker
95-
self.reconnectionIterator = reconnectionIterator or defaultReconnectionIterator
95+
self.reconnectionIterator = (reconnectionIterator or
96+
defaultReconnectionIterator)
9697

9798
if not reactor:
9899
from twisted.internet import reactor
@@ -129,8 +130,9 @@ def callChecking(self, method, *args, **kwargs):
129130

130131
def checkForDeadConnection(self, f):
131132
"""
132-
Get passed a :tm:`Failure <python.failure.Failure>` instance and determine
133-
if it means that the connection is dead. If so, start reconnecting.
133+
Get passed a :tm:`Failure <python.failure.Failure>` instance and
134+
determine if it means that the connection is dead. If so, start
135+
reconnecting.
134136
"""
135137
# if the error does not indicate that the connection is dead, just
136138
# return the failure
@@ -209,8 +211,8 @@ def addRecoveryHandler(self, handler):
209211

210212
def removeRecoveryHandler(self, handler):
211213
"""
212-
Remove a previously added recovery handler. Removing a handler that's never
213-
been added will be ignored.
214+
Remove a previously added recovery handler. Removing a handler that's
215+
never been added will be ignored.
214216
215217
:param handler: A callable that should no longer be called when the
216218
connection recovers.

txpostgres/retrying.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ def start(self, backoffIterator=None, failureTester=None):
145145
a :tm:`Failure <python.failure.Failure>` instance each time the
146146
function being retried fails. It should return
147147
:class:`None` if the call should be retried or a
148-
:tm:`Failure <python.failure.Failure>` if the retrying process should
149-
be stopped. If :class:`None` is used for this parameter, retrying
150-
will never stop until the backoff iterator is exhausted.
148+
:tm:`Failure <python.failure.Failure>` if the retrying process
149+
should be stopped. If :class:`None` is used for this parameter,
150+
retrying will never stop until the backoff iterator is exhausted.
151151
:type failureTester: callable
152152
"""
153153
self.resetBackoff(backoffIterator)

0 commit comments

Comments
 (0)
0