summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/deprecated_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/orm/deprecated_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/orm/deprecated_interfaces.py')
-rw-r--r--lib/sqlalchemy/orm/deprecated_interfaces.py150
1 files changed, 103 insertions, 47 deletions
diff --git a/lib/sqlalchemy/orm/deprecated_interfaces.py b/lib/sqlalchemy/orm/deprecated_interfaces.py
index 426288e03..6b51404d0 100644
--- a/lib/sqlalchemy/orm/deprecated_interfaces.py
+++ b/lib/sqlalchemy/orm/deprecated_interfaces.py
@@ -58,23 +58,25 @@ class MapperExtension(object):
@classmethod
def _adapt_instrument_class(cls, self, listener):
- cls._adapt_listener_methods(self, listener, ('instrument_class',))
+ cls._adapt_listener_methods(self, listener, ("instrument_class",))
@classmethod
def _adapt_listener(cls, self, listener):
cls._adapt_listener_methods(
- self, listener,
+ self,
+ listener,
(
- 'init_instance',
- 'init_failed',
- 'reconstruct_instance',
- 'before_insert',
- 'after_insert',
- 'before_update',
- 'after_update',
- 'before_delete',
- 'after_delete'
- ))
+ "init_instance",
+ "init_failed",
+ "reconstruct_instance",
+ "before_insert",
+ "after_insert",
+ "before_update",
+ "after_update",
+ "before_delete",
+ "after_delete",
+ ),
+ )
@classmethod
def _adapt_listener_methods(cls, self, listener, methods):
@@ -84,36 +86,75 @@ class MapperExtension(object):
ls_meth = getattr(listener, meth)
if not util.methods_equivalent(me_meth, ls_meth):
- if meth == 'reconstruct_instance':
+ if meth == "reconstruct_instance":
+
def go(ls_meth):
def reconstruct(instance, ctx):
ls_meth(self, instance)
+
return reconstruct
- event.listen(self.class_manager, 'load',
- go(ls_meth), raw=False, propagate=True)
- elif meth == 'init_instance':
+
+ event.listen(
+ self.class_manager,
+ "load",
+ go(ls_meth),
+ raw=False,
+ propagate=True,
+ )
+ elif meth == "init_instance":
+
def go(ls_meth):
def init_instance(instance, args, kwargs):
- ls_meth(self, self.class_,
- self.class_manager.original_init,
- instance, args, kwargs)
+ ls_meth(
+ self,
+ self.class_,
+ self.class_manager.original_init,
+ instance,
+ args,
+ kwargs,
+ )
+
return init_instance
- event.listen(self.class_manager, 'init',
- go(ls_meth), raw=False, propagate=True)
- elif meth == 'init_failed':
+
+ event.listen(
+ self.class_manager,
+ "init",
+ go(ls_meth),
+ raw=False,
+ propagate=True,
+ )
+ elif meth == "init_failed":
+
def go(ls_meth):
def init_failed(instance, args, kwargs):
util.warn_exception(
- ls_meth, self, self.class_,
+ ls_meth,
+ self,
+ self.class_,
self.class_manager.original_init,
- instance, args, kwargs)
+ instance,
+ args,
+ kwargs,
+ )
return init_failed
- event.listen(self.class_manager, 'init_failure',
- go(ls_meth), raw=False, propagate=True)
+
+ event.listen(
+ self.class_manager,
+ "init_failure",
+ go(ls_meth),
+ raw=False,
+ propagate=True,
+ )
else:
- event.listen(self, "%s" % meth, ls_meth,
- raw=False, retval=True, propagate=True)
+ event.listen(
+ self,
+ "%s" % meth,
+ ls_meth,
+ raw=False,
+ retval=True,
+ propagate=True,
+ )
def instrument_class(self, mapper, class_):
"""Receive a class when the mapper is first constructed, and has
@@ -302,16 +343,16 @@ class SessionExtension(object):
@classmethod
def _adapt_listener(cls, self, listener):
for meth in [
- 'before_commit',
- 'after_commit',
- 'after_rollback',
- 'before_flush',
- 'after_flush',
- 'after_flush_postexec',
- 'after_begin',
- 'after_attach',
- 'after_bulk_update',
- 'after_bulk_delete',
+ "before_commit",
+ "after_commit",
+ "after_rollback",
+ "before_flush",
+ "after_flush",
+ "after_flush_postexec",
+ "after_begin",
+ "after_attach",
+ "after_bulk_update",
+ "after_bulk_delete",
]:
me_meth = getattr(SessionExtension, meth)
ls_meth = getattr(listener, meth)
@@ -450,15 +491,30 @@ class AttributeExtension(object):
@classmethod
def _adapt_listener(cls, self, listener):
- event.listen(self, 'append', listener.append,
- active_history=listener.active_history,
- raw=True, retval=True)
- event.listen(self, 'remove', listener.remove,
- active_history=listener.active_history,
- raw=True, retval=True)
- event.listen(self, 'set', listener.set,
- active_history=listener.active_history,
- raw=True, retval=True)
+ event.listen(
+ self,
+ "append",
+ listener.append,
+ active_history=listener.active_history,
+ raw=True,
+ retval=True,
+ )
+ event.listen(
+ self,
+ "remove",
+ listener.remove,
+ active_history=listener.active_history,
+ raw=True,
+ retval=True,
+ )
+ event.listen(
+ self,
+ "set",
+ listener.set,
+ active_history=listener.active_history,
+ raw=True,
+ retval=True,
+ )
def append(self, state, value, initiator):
"""Receive a collection append event.