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/ext/compiler.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/ext/compiler.py')
-rw-r--r-- | lib/sqlalchemy/ext/compiler.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py index 6a0909d36..220b2c057 100644 --- a/lib/sqlalchemy/ext/compiler.py +++ b/lib/sqlalchemy/ext/compiler.py @@ -407,37 +407,44 @@ def compiles(class_, *specs): def decorate(fn): # get an existing @compiles handler - existing = class_.__dict__.get('_compiler_dispatcher', None) + existing = class_.__dict__.get("_compiler_dispatcher", None) # get the original handler. All ClauseElement classes have one # of these, but some TypeEngine classes will not. - existing_dispatch = getattr(class_, '_compiler_dispatch', None) + existing_dispatch = getattr(class_, "_compiler_dispatch", None) if not existing: existing = _dispatcher() if existing_dispatch: + def _wrap_existing_dispatch(element, compiler, **kw): try: return existing_dispatch(element, compiler, **kw) except exc.UnsupportedCompilationError: raise exc.CompileError( "%s construct has no default " - "compilation handler." % type(element)) - existing.specs['default'] = _wrap_existing_dispatch + "compilation handler." % type(element) + ) + + existing.specs["default"] = _wrap_existing_dispatch # TODO: why is the lambda needed ? - setattr(class_, '_compiler_dispatch', - lambda *arg, **kw: existing(*arg, **kw)) - setattr(class_, '_compiler_dispatcher', existing) + setattr( + class_, + "_compiler_dispatch", + lambda *arg, **kw: existing(*arg, **kw), + ) + setattr(class_, "_compiler_dispatcher", existing) if specs: for s in specs: existing.specs[s] = fn else: - existing.specs['default'] = fn + existing.specs["default"] = fn return fn + return decorate @@ -445,7 +452,7 @@ def deregister(class_): """Remove all custom compilers associated with a given :class:`.ClauseElement` type.""" - if hasattr(class_, '_compiler_dispatcher'): + if hasattr(class_, "_compiler_dispatcher"): # regenerate default _compiler_dispatch visitors._generate_dispatch(class_) # remove custom directive @@ -461,10 +468,11 @@ class _dispatcher(object): fn = self.specs.get(compiler.dialect.name, None) if not fn: try: - fn = self.specs['default'] + fn = self.specs["default"] except KeyError: raise exc.CompileError( "%s construct has no default " - "compilation handler." % type(element)) + "compilation handler." % type(element) + ) return fn(element, compiler, **kw) |