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/dialects/postgresql/json.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/dialects/postgresql/json.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/json.py | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/json.py b/lib/sqlalchemy/dialects/postgresql/json.py index e9256daf3..f9421de37 100644 --- a/lib/sqlalchemy/dialects/postgresql/json.py +++ b/lib/sqlalchemy/dialects/postgresql/json.py @@ -12,44 +12,58 @@ from ...sql import operators from ...sql import elements from ... import util -__all__ = ('JSON', 'JSONB') +__all__ = ("JSON", "JSONB") idx_precedence = operators._PRECEDENCE[operators.json_getitem_op] ASTEXT = operators.custom_op( - "->>", precedence=idx_precedence, natural_self_precedent=True, - eager_grouping=True + "->>", + precedence=idx_precedence, + natural_self_precedent=True, + eager_grouping=True, ) JSONPATH_ASTEXT = operators.custom_op( - "#>>", precedence=idx_precedence, natural_self_precedent=True, - eager_grouping=True + "#>>", + precedence=idx_precedence, + natural_self_precedent=True, + eager_grouping=True, ) HAS_KEY = operators.custom_op( - "?", precedence=idx_precedence, natural_self_precedent=True, - eager_grouping=True + "?", + precedence=idx_precedence, + natural_self_precedent=True, + eager_grouping=True, ) HAS_ALL = operators.custom_op( - "?&", precedence=idx_precedence, natural_self_precedent=True, - eager_grouping=True + "?&", + precedence=idx_precedence, + natural_self_precedent=True, + eager_grouping=True, ) HAS_ANY = operators.custom_op( - "?|", precedence=idx_precedence, natural_self_precedent=True, - eager_grouping=True + "?|", + precedence=idx_precedence, + natural_self_precedent=True, + eager_grouping=True, ) CONTAINS = operators.custom_op( - "@>", precedence=idx_precedence, natural_self_precedent=True, - eager_grouping=True + "@>", + precedence=idx_precedence, + natural_self_precedent=True, + eager_grouping=True, ) CONTAINED_BY = operators.custom_op( - "<@", precedence=idx_precedence, natural_self_precedent=True, - eager_grouping=True + "<@", + precedence=idx_precedence, + natural_self_precedent=True, + eager_grouping=True, ) @@ -59,7 +73,7 @@ class JSONPathType(sqltypes.JSON.JSONPathType): def process(value): assert isinstance(value, util.collections_abc.Sequence) - tokens = [util.text_type(elem)for elem in value] + tokens = [util.text_type(elem) for elem in value] value = "{%s}" % (", ".join(tokens)) if super_proc: value = super_proc(value) @@ -72,7 +86,7 @@ class JSONPathType(sqltypes.JSON.JSONPathType): def process(value): assert isinstance(value, util.collections_abc.Sequence) - tokens = [util.text_type(elem)for elem in value] + tokens = [util.text_type(elem) for elem in value] value = "{%s}" % (", ".join(tokens)) if super_proc: value = super_proc(value) @@ -80,6 +94,7 @@ class JSONPathType(sqltypes.JSON.JSONPathType): return process + colspecs[sqltypes.JSON.JSONPathType] = JSONPathType @@ -203,16 +218,19 @@ class JSON(sqltypes.JSON): if isinstance(self.expr.right.type, sqltypes.JSON.JSONPathType): return self.expr.left.operate( JSONPATH_ASTEXT, - self.expr.right, result_type=self.type.astext_type) + self.expr.right, + result_type=self.type.astext_type, + ) else: return self.expr.left.operate( - ASTEXT, self.expr.right, result_type=self.type.astext_type) + ASTEXT, self.expr.right, result_type=self.type.astext_type + ) comparator_factory = Comparator colspecs[sqltypes.JSON] = JSON -ischema_names['json'] = JSON +ischema_names["json"] = JSON class JSONB(JSON): @@ -259,7 +277,7 @@ class JSONB(JSON): """ - __visit_name__ = 'JSONB' + __visit_name__ = "JSONB" class Comparator(JSON.Comparator): """Define comparison operations for :class:`.JSON`.""" @@ -291,8 +309,10 @@ class JSONB(JSON): keys of the argument jsonb expression. """ return self.operate( - CONTAINED_BY, other, result_type=sqltypes.Boolean) + CONTAINED_BY, other, result_type=sqltypes.Boolean + ) comparator_factory = Comparator -ischema_names['jsonb'] = JSONB + +ischema_names["jsonb"] = JSONB |