diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-06 01:14:26 -0500 |
|---|---|---|
| committer | mike bayer <mike_mp@zzzcomputing.com> | 2019-01-06 17:34:50 +0000 |
| commit | 1e1a38e7801f410f244e4bbb44ec795ae152e04e (patch) | |
| tree | 28e725c5c8188bd0cfd133d1e268dbca9b524978 /lib/sqlalchemy/event/registry.py | |
| parent | 404e69426b05a82d905cbb3ad33adafccddb00dd (diff) | |
| download | sqlalchemy-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/event/registry.py')
| -rw-r--r-- | lib/sqlalchemy/event/registry.py | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/lib/sqlalchemy/event/registry.py b/lib/sqlalchemy/event/registry.py index 8d4bada0b..c862ae403 100644 --- a/lib/sqlalchemy/event/registry.py +++ b/lib/sqlalchemy/event/registry.py @@ -141,11 +141,15 @@ class _EventKey(object): """ __slots__ = ( - 'target', 'identifier', 'fn', 'fn_key', 'fn_wrap', 'dispatch_target' + "target", + "identifier", + "fn", + "fn_key", + "fn_wrap", + "dispatch_target", ) - def __init__(self, target, identifier, - fn, dispatch_target, _fn_wrap=None): + def __init__(self, target, identifier, fn, dispatch_target, _fn_wrap=None): self.target = target self.identifier = identifier self.fn = fn @@ -169,7 +173,7 @@ class _EventKey(object): self.identifier, self.fn, self.dispatch_target, - _fn_wrap=fn_wrap + _fn_wrap=fn_wrap, ) def with_dispatch_target(self, dispatch_target): @@ -181,15 +185,18 @@ class _EventKey(object): self.identifier, self.fn, dispatch_target, - _fn_wrap=self.fn_wrap + _fn_wrap=self.fn_wrap, ) def listen(self, *args, **kw): once = kw.pop("once", False) named = kw.pop("named", False) - target, identifier, fn = \ - self.dispatch_target, self.identifier, self._listen_fn + target, identifier, fn = ( + self.dispatch_target, + self.identifier, + self._listen_fn, + ) dispatch_collection = getattr(target.dispatch, identifier) @@ -198,8 +205,9 @@ class _EventKey(object): self = self.with_wrapper(adjusted_fn) if once: - self.with_wrapper( - util.only_once(self._listen_fn)).listen(*args, **kw) + self.with_wrapper(util.only_once(self._listen_fn)).listen( + *args, **kw + ) else: self.dispatch_target.dispatch._listen(self, *args, **kw) @@ -208,8 +216,8 @@ class _EventKey(object): if key not in _key_to_collection: raise exc.InvalidRequestError( - "No listeners found for event %s / %r / %s " % - (self.target, self.identifier, self.fn) + "No listeners found for event %s / %r / %s " + % (self.target, self.identifier, self.fn) ) dispatch_reg = _key_to_collection.pop(key) @@ -224,20 +232,26 @@ class _EventKey(object): """ return self._key in _key_to_collection - def base_listen(self, propagate=False, insert=False, - named=False, retval=None): + def base_listen( + self, propagate=False, insert=False, named=False, retval=None + ): - target, identifier, fn = \ - self.dispatch_target, self.identifier, self._listen_fn + target, identifier, fn = ( + self.dispatch_target, + self.identifier, + self._listen_fn, + ) dispatch_collection = getattr(target.dispatch, identifier) if insert: - dispatch_collection.\ - for_modify(target.dispatch).insert(self, propagate) + dispatch_collection.for_modify(target.dispatch).insert( + self, propagate + ) else: - dispatch_collection.\ - for_modify(target.dispatch).append(self, propagate) + dispatch_collection.for_modify(target.dispatch).append( + self, propagate + ) @property def _listen_fn(self): |
