summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/interfaces.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 01:14:26 -0500
committermike bayer <mike_mp@zzzcomputing.com>2019-01-06 17:34:50 +0000
commit1e1a38e7801f410f244e4bbb44ec795ae152e04e (patch)
tree28e725c5c8188bd0cfd133d1e268dbca9b524978 /lib/sqlalchemy/interfaces.py
parent404e69426b05a82d905cbb3ad33adafccddb00dd (diff)
downloadsqlalchemy-1e1a38e7801f410f244e4bbb44ec795ae152e04e.tar.gz
Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
Diffstat (limited to 'lib/sqlalchemy/interfaces.py')
-rw-r--r--lib/sqlalchemy/interfaces.py102
1 files changed, 53 insertions, 49 deletions
diff --git a/lib/sqlalchemy/interfaces.py b/lib/sqlalchemy/interfaces.py
index 30698ea33..f352f7f26 100644
--- a/lib/sqlalchemy/interfaces.py
+++ b/lib/sqlalchemy/interfaces.py
@@ -80,17 +80,18 @@ class PoolListener(object):
"""
- listener = util.as_interface(listener,
- methods=('connect', 'first_connect',
- 'checkout', 'checkin'))
- if hasattr(listener, 'connect'):
- event.listen(self, 'connect', listener.connect)
- if hasattr(listener, 'first_connect'):
- event.listen(self, 'first_connect', listener.first_connect)
- if hasattr(listener, 'checkout'):
- event.listen(self, 'checkout', listener.checkout)
- if hasattr(listener, 'checkin'):
- event.listen(self, 'checkin', listener.checkin)
+ listener = util.as_interface(
+ listener,
+ methods=("connect", "first_connect", "checkout", "checkin"),
+ )
+ if hasattr(listener, "connect"):
+ event.listen(self, "connect", listener.connect)
+ if hasattr(listener, "first_connect"):
+ event.listen(self, "first_connect", listener.first_connect)
+ if hasattr(listener, "checkout"):
+ event.listen(self, "checkout", listener.checkout)
+ if hasattr(listener, "checkin"):
+ event.listen(self, "checkin", listener.checkin)
def connect(self, dbapi_con, con_record):
"""Called once for each new DB-API connection or Pool's ``creator()``.
@@ -187,27 +188,20 @@ class ConnectionProxy(object):
@classmethod
def _adapt_listener(cls, self, listener):
-
def adapt_execute(conn, clauseelement, multiparams, params):
-
def execute_wrapper(clauseelement, *multiparams, **params):
return clauseelement, multiparams, params
- return listener.execute(conn, execute_wrapper,
- clauseelement, *multiparams,
- **params)
+ return listener.execute(
+ conn, execute_wrapper, clauseelement, *multiparams, **params
+ )
- event.listen(self, 'before_execute', adapt_execute)
+ event.listen(self, "before_execute", adapt_execute)
- def adapt_cursor_execute(conn, cursor, statement,
- parameters, context, executemany):
-
- def execute_wrapper(
- cursor,
- statement,
- parameters,
- context,
- ):
+ def adapt_cursor_execute(
+ conn, cursor, statement, parameters, context, executemany
+ ):
+ def execute_wrapper(cursor, statement, parameters, context):
return statement, parameters
return listener.cursor_execute(
@@ -217,46 +211,56 @@ class ConnectionProxy(object):
parameters,
context,
executemany,
- )
+ )
- event.listen(self, 'before_cursor_execute', adapt_cursor_execute)
+ event.listen(self, "before_cursor_execute", adapt_cursor_execute)
def do_nothing_callback(*arg, **kw):
pass
def adapt_listener(fn):
-
def go(conn, *arg, **kw):
fn(conn, do_nothing_callback, *arg, **kw)
return util.update_wrapper(go, fn)
- event.listen(self, 'begin', adapt_listener(listener.begin))
- event.listen(self, 'rollback',
- adapt_listener(listener.rollback))
- event.listen(self, 'commit', adapt_listener(listener.commit))
- event.listen(self, 'savepoint',
- adapt_listener(listener.savepoint))
- event.listen(self, 'rollback_savepoint',
- adapt_listener(listener.rollback_savepoint))
- event.listen(self, 'release_savepoint',
- adapt_listener(listener.release_savepoint))
- event.listen(self, 'begin_twophase',
- adapt_listener(listener.begin_twophase))
- event.listen(self, 'prepare_twophase',
- adapt_listener(listener.prepare_twophase))
- event.listen(self, 'rollback_twophase',
- adapt_listener(listener.rollback_twophase))
- event.listen(self, 'commit_twophase',
- adapt_listener(listener.commit_twophase))
+ event.listen(self, "begin", adapt_listener(listener.begin))
+ event.listen(self, "rollback", adapt_listener(listener.rollback))
+ event.listen(self, "commit", adapt_listener(listener.commit))
+ event.listen(self, "savepoint", adapt_listener(listener.savepoint))
+ event.listen(
+ self,
+ "rollback_savepoint",
+ adapt_listener(listener.rollback_savepoint),
+ )
+ event.listen(
+ self,
+ "release_savepoint",
+ adapt_listener(listener.release_savepoint),
+ )
+ event.listen(
+ self, "begin_twophase", adapt_listener(listener.begin_twophase)
+ )
+ event.listen(
+ self, "prepare_twophase", adapt_listener(listener.prepare_twophase)
+ )
+ event.listen(
+ self,
+ "rollback_twophase",
+ adapt_listener(listener.rollback_twophase),
+ )
+ event.listen(
+ self, "commit_twophase", adapt_listener(listener.commit_twophase)
+ )
def execute(self, conn, execute, clauseelement, *multiparams, **params):
"""Intercept high level execute() events."""
return execute(clauseelement, *multiparams, **params)
- def cursor_execute(self, execute, cursor, statement, parameters,
- context, executemany):
+ def cursor_execute(
+ self, execute, cursor, statement, parameters, context, executemany
+ ):
"""Intercept low-level cursor execute() events."""
return execute(cursor, statement, parameters, context)