summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 01:19:47 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 18:23:11 -0500
commit1e278de4cc9a4181e0747640a960e80efcea1ca9 (patch)
tree13d0c035807613bfa07e734acad79b9c843cb8b0 /lib/sqlalchemy/sql
parent1e1a38e7801f410f244e4bbb44ec795ae152e04e (diff)
downloadsqlalchemy-1e278de4cc9a4181e0747640a960e80efcea1ca9.tar.gz
Post black reformatting
Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/__init__.py149
-rw-r--r--lib/sqlalchemy/sql/annotation.py2
-rw-r--r--lib/sqlalchemy/sql/base.py17
-rw-r--r--lib/sqlalchemy/sql/compiler.py31
-rw-r--r--lib/sqlalchemy/sql/crud.py34
-rw-r--r--lib/sqlalchemy/sql/ddl.py16
-rw-r--r--lib/sqlalchemy/sql/default_comparator.py54
-rw-r--r--lib/sqlalchemy/sql/dml.py54
-rw-r--r--lib/sqlalchemy/sql/elements.py59
-rw-r--r--lib/sqlalchemy/sql/expression.py184
-rw-r--r--lib/sqlalchemy/sql/functions.py56
-rw-r--r--lib/sqlalchemy/sql/naming.py28
-rw-r--r--lib/sqlalchemy/sql/operators.py41
-rw-r--r--lib/sqlalchemy/sql/schema.py64
-rw-r--r--lib/sqlalchemy/sql/selectable.py99
-rw-r--r--lib/sqlalchemy/sql/sqltypes.py120
-rw-r--r--lib/sqlalchemy/sql/type_api.py19
-rw-r--r--lib/sqlalchemy/sql/util.py52
-rw-r--r--lib/sqlalchemy/sql/visitors.py4
19 files changed, 557 insertions, 526 deletions
diff --git a/lib/sqlalchemy/sql/__init__.py b/lib/sqlalchemy/sql/__init__.py
index 87e2fb6c3..a46acc076 100644
--- a/lib/sqlalchemy/sql/__init__.py
+++ b/lib/sqlalchemy/sql/__init__.py
@@ -5,77 +5,74 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from .expression import (
- Alias,
- ClauseElement,
- ColumnCollection,
- ColumnElement,
- CompoundSelect,
- Delete,
- FromClause,
- Insert,
- Join,
- Select,
- Selectable,
- TableClause,
- TableSample,
- Update,
- alias,
- and_,
- any_,
- all_,
- asc,
- between,
- bindparam,
- case,
- cast,
- collate,
- column,
- delete,
- desc,
- distinct,
- except_,
- except_all,
- exists,
- extract,
- false,
- False_,
- func,
- funcfilter,
- insert,
- intersect,
- intersect_all,
- join,
- label,
- lateral,
- literal,
- literal_column,
- modifier,
- not_,
- null,
- nullsfirst,
- nullslast,
- or_,
- outerjoin,
- outparam,
- over,
- quoted_name,
- select,
- subquery,
- table,
- tablesample,
- text,
- true,
- True_,
- tuple_,
- type_coerce,
- union,
- union_all,
- update,
- within_group,
-)
-
-from .visitors import ClauseVisitor
+from .expression import Alias # noqa
+from .expression import alias # noqa
+from .expression import all_ # noqa
+from .expression import and_ # noqa
+from .expression import any_ # noqa
+from .expression import asc # noqa
+from .expression import between # noqa
+from .expression import bindparam # noqa
+from .expression import case # noqa
+from .expression import cast # noqa
+from .expression import ClauseElement # noqa
+from .expression import collate # noqa
+from .expression import column # noqa
+from .expression import ColumnCollection # noqa
+from .expression import ColumnElement # noqa
+from .expression import CompoundSelect # noqa
+from .expression import Delete # noqa
+from .expression import delete # noqa
+from .expression import desc # noqa
+from .expression import distinct # noqa
+from .expression import except_ # noqa
+from .expression import except_all # noqa
+from .expression import exists # noqa
+from .expression import extract # noqa
+from .expression import false # noqa
+from .expression import False_ # noqa
+from .expression import FromClause # noqa
+from .expression import func # noqa
+from .expression import funcfilter # noqa
+from .expression import Insert # noqa
+from .expression import insert # noqa
+from .expression import intersect # noqa
+from .expression import intersect_all # noqa
+from .expression import Join # noqa
+from .expression import join # noqa
+from .expression import label # noqa
+from .expression import lateral # noqa
+from .expression import literal # noqa
+from .expression import literal_column # noqa
+from .expression import modifier # noqa
+from .expression import not_ # noqa
+from .expression import null # noqa
+from .expression import nullsfirst # noqa
+from .expression import nullslast # noqa
+from .expression import or_ # noqa
+from .expression import outerjoin # noqa
+from .expression import outparam # noqa
+from .expression import over # noqa
+from .expression import quoted_name # noqa
+from .expression import Select # noqa
+from .expression import select # noqa
+from .expression import Selectable # noqa
+from .expression import subquery # noqa
+from .expression import table # noqa
+from .expression import TableClause # noqa
+from .expression import TableSample # noqa
+from .expression import tablesample # noqa
+from .expression import text # noqa
+from .expression import true # noqa
+from .expression import True_ # noqa
+from .expression import tuple_ # noqa
+from .expression import type_coerce # noqa
+from .expression import union # noqa
+from .expression import union_all # noqa
+from .expression import Update # noqa
+from .expression import update # noqa
+from .expression import within_group # noqa
+from .visitors import ClauseVisitor # noqa
def __go(lcls):
@@ -90,9 +87,11 @@ def __go(lcls):
if not (name.startswith("_") or _inspect.ismodule(obj))
)
- from .annotation import _prepare_annotations, Annotated
- from .elements import AnnotatedColumnElement, ClauseList
- from .selectable import AnnotatedFromClause
+ from .annotation import _prepare_annotations
+ from .annotation import Annotated # noqa
+ from .elements import AnnotatedColumnElement
+ from .elements import ClauseList # noqa
+ from .selectable import AnnotatedFromClause # noqa
_prepare_annotations(ColumnElement, AnnotatedColumnElement)
_prepare_annotations(FromClause, AnnotatedFromClause)
@@ -100,7 +99,7 @@ def __go(lcls):
_sa_util.dependencies.resolve_all("sqlalchemy.sql")
- from . import naming
+ from . import naming # noqa
__go(locals())
diff --git a/lib/sqlalchemy/sql/annotation.py b/lib/sqlalchemy/sql/annotation.py
index 64cfa630e..0dc70a812 100644
--- a/lib/sqlalchemy/sql/annotation.py
+++ b/lib/sqlalchemy/sql/annotation.py
@@ -11,8 +11,8 @@ associations.
"""
-from .. import util
from . import operators
+from .. import util
class Annotated(object):
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py
index 45db215fe..1de7c5ea6 100644
--- a/lib/sqlalchemy/sql/base.py
+++ b/lib/sqlalchemy/sql/base.py
@@ -10,11 +10,14 @@
"""
-from .. import util, exc
import itertools
-from .visitors import ClauseVisitor
import re
+from .visitors import ClauseVisitor
+from .. import exc
+from .. import util
+
+
PARSE_AUTOCOMMIT = util.symbol("PARSE_AUTOCOMMIT")
NO_ARG = util.symbol("NO_ARG")
@@ -517,7 +520,7 @@ class ColumnCollection(util.OrderedProperties):
def __delitem__(self, key):
raise NotImplementedError()
- def __setattr__(self, key, object):
+ def __setattr__(self, key, obj):
raise NotImplementedError()
def __setitem__(self, key, value):
@@ -557,16 +560,16 @@ class ColumnCollection(util.OrderedProperties):
c for c in self._all_columns if c is not column
]
- def update(self, iter):
- cols = list(iter)
+ def update(self, iter_):
+ cols = list(iter_)
all_col_set = set(self._all_columns)
self._all_columns.extend(
c for label, c in cols if c not in all_col_set
)
self._data.update((label, c) for label, c in cols)
- def extend(self, iter):
- cols = list(iter)
+ def extend(self, iter_):
+ cols = list(iter_)
all_col_set = set(self._all_columns)
self._all_columns.extend(c for c in cols if c not in all_col_set)
self._data.update((c.key, c) for c in cols)
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index f641d0a84..c752da013 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -24,19 +24,20 @@ To generate user-defined SQL strings, see
"""
import contextlib
-import re
-from . import (
- schema,
- sqltypes,
- operators,
- functions,
- visitors,
- elements,
- selectable,
- crud,
-)
-from .. import util, exc
import itertools
+import re
+
+from . import crud
+from . import elements
+from . import functions
+from . import operators
+from . import schema
+from . import selectable
+from . import sqltypes
+from . import visitors
+from .. import exc
+from .. import util
+
RESERVED_WORDS = set(
[
@@ -2392,11 +2393,7 @@ class SQLCompiler(Compiled):
table_text = preparer.format_table(insert_stmt.table)
if insert_stmt._hints:
- dialect_hints, table_text = self._setup_crud_hints(
- insert_stmt, table_text
- )
- else:
- dialect_hints = None
+ _, table_text = self._setup_crud_hints(insert_stmt, table_text)
text += table_text
diff --git a/lib/sqlalchemy/sql/crud.py b/lib/sqlalchemy/sql/crud.py
index 602b91a25..6452badd2 100644
--- a/lib/sqlalchemy/sql/crud.py
+++ b/lib/sqlalchemy/sql/crud.py
@@ -9,11 +9,13 @@
within INSERT and UPDATE statements.
"""
-from .. import util
-from .. import exc
+import operator
+
from . import dml
from . import elements
-import operator
+from .. import exc
+from .. import util
+
REQUIRED = util.symbol(
"REQUIRED",
@@ -97,9 +99,11 @@ def _get_crud_params(compiler, stmt, **kw):
# getters - these are normally just column.key,
# but in the case of mysql multi-table update, the rules for
# .key must conditionally take tablename into account
- _column_as_key, _getattr_col_key, _col_bind_name = _key_getters_for_crud_column(
- compiler, stmt
- )
+ (
+ _column_as_key,
+ _getattr_col_key,
+ _col_bind_name,
+ ) = _key_getters_for_crud_column(compiler, stmt)
# if we have statement parameters - set defaults in the
# compiled params
@@ -241,9 +245,12 @@ def _scan_insert_from_select_cols(
kw,
):
- need_pks, implicit_returning, implicit_return_defaults, postfetch_lastrowid = _get_returning_modifiers(
- compiler, stmt
- )
+ (
+ need_pks,
+ implicit_returning,
+ implicit_return_defaults,
+ postfetch_lastrowid,
+ ) = _get_returning_modifiers(compiler, stmt)
cols = [stmt.table.c[_column_as_key(name)] for name in stmt.select_names]
@@ -286,9 +293,12 @@ def _scan_cols(
kw,
):
- need_pks, implicit_returning, implicit_return_defaults, postfetch_lastrowid = _get_returning_modifiers(
- compiler, stmt
- )
+ (
+ need_pks,
+ implicit_returning,
+ implicit_return_defaults,
+ postfetch_lastrowid,
+ ) = _get_returning_modifiers(compiler, stmt)
if stmt._parameter_ordering:
parameter_ordering = [
diff --git a/lib/sqlalchemy/sql/ddl.py b/lib/sqlalchemy/sql/ddl.py
index f21b3d7f0..f247fa782 100644
--- a/lib/sqlalchemy/sql/ddl.py
+++ b/lib/sqlalchemy/sql/ddl.py
@@ -10,12 +10,15 @@ to invoke them for a create/drop call.
"""
-from .. import util
+from .base import _bind_or_error
+from .base import _generative
+from .base import Executable
+from .base import SchemaVisitor
from .elements import ClauseElement
-from .base import Executable, _generative, SchemaVisitor, _bind_or_error
-from ..util import topological
from .. import event
from .. import exc
+from .. import util
+from ..util import topological
class _DDLCompiles(ClauseElement):
@@ -168,7 +171,7 @@ class DDLElement(Executable, _DDLCompiles):
DDL('something').execute_if(dialect=('postgresql', 'mysql'))
- :param callable_: A callable, which will be invoked with
+ :param callable\_: A callable, which will be invoked with
four positional arguments as well as optional keyword
arguments:
@@ -815,10 +818,13 @@ class SchemaGenerator(DDLBase):
include_foreign_key_constraints = None
self.connection.execute(
+ # fmt: off
CreateTable(
table,
- include_foreign_key_constraints=include_foreign_key_constraints,
+ include_foreign_key_constraints= # noqa
+ include_foreign_key_constraints,
)
+ # fmt: on
)
if hasattr(table, "indexes"):
diff --git a/lib/sqlalchemy/sql/default_comparator.py b/lib/sqlalchemy/sql/default_comparator.py
index fa0052198..69196341f 100644
--- a/lib/sqlalchemy/sql/default_comparator.py
+++ b/lib/sqlalchemy/sql/default_comparator.py
@@ -8,34 +8,34 @@
"""Default implementation of SQL comparison operations.
"""
-from .. import exc, util
-from . import type_api
from . import operators
-from .elements import (
- BindParameter,
- True_,
- False_,
- BinaryExpression,
- Null,
- _const_expr,
- _clause_element_as_expr,
- ClauseList,
- ColumnElement,
- TextClause,
- UnaryExpression,
- collate,
- _is_literal,
- _literal_as_text,
- ClauseElement,
- and_,
- or_,
- Slice,
- Visitable,
- _literal_as_binds,
- CollectionAggregate,
- Tuple,
-)
-from .selectable import SelectBase, Alias, Selectable, ScalarSelect
+from . import type_api
+from .elements import _clause_element_as_expr
+from .elements import _const_expr
+from .elements import _is_literal
+from .elements import _literal_as_text
+from .elements import and_
+from .elements import BinaryExpression
+from .elements import BindParameter
+from .elements import ClauseElement
+from .elements import ClauseList
+from .elements import collate
+from .elements import CollectionAggregate
+from .elements import ColumnElement
+from .elements import False_
+from .elements import Null
+from .elements import or_
+from .elements import TextClause
+from .elements import True_
+from .elements import Tuple
+from .elements import UnaryExpression
+from .elements import Visitable
+from .selectable import Alias
+from .selectable import ScalarSelect
+from .selectable import Selectable
+from .selectable import SelectBase
+from .. import exc
+from .. import util
def _boolean_compare(
diff --git a/lib/sqlalchemy/sql/dml.py b/lib/sqlalchemy/sql/dml.py
index 0cea5ccc4..39a3b39d3 100644
--- a/lib/sqlalchemy/sql/dml.py
+++ b/lib/sqlalchemy/sql/dml.py
@@ -9,29 +9,22 @@ Provide :class:`.Insert`, :class:`.Update` and :class:`.Delete`.
"""
-from .base import (
- Executable,
- _generative,
- _from_objects,
- DialectKWArgs,
- ColumnCollection,
-)
-from .elements import (
- ClauseElement,
- _literal_as_text,
- Null,
- and_,
- _clone,
- _column_as_key,
-)
-from .selectable import (
- _interpret_as_from,
- _interpret_as_select,
- HasPrefixes,
- HasCTE,
-)
-from .. import util
+from .base import _from_objects
+from .base import _generative
+from .base import DialectKWArgs
+from .base import Executable
+from .elements import _clone
+from .elements import _column_as_key
+from .elements import _literal_as_text
+from .elements import and_
+from .elements import ClauseElement
+from .elements import Null
+from .selectable import _interpret_as_from
+from .selectable import _interpret_as_select
+from .selectable import HasCTE
+from .selectable import HasPrefixes
from .. import exc
+from .. import util
class UpdateBase(
@@ -372,9 +365,10 @@ class ValuesBase(UpdateBase):
v = {}
if self.parameters is None:
- self.parameters, self._has_multi_parameters = self._process_colparams(
- v
- )
+ (
+ self.parameters,
+ self._has_multi_parameters,
+ ) = self._process_colparams(v)
else:
if self._has_multi_parameters:
self.parameters = list(self.parameters)
@@ -714,17 +708,17 @@ class Update(ValuesBase):
:meth:`.ResultProxy.last_updated_params`.
:param preserve_parameter_order: if True, the update statement is
- expected to receive parameters **only** via the :meth:`.Update.values`
- method, and they must be passed as a Python ``list`` of 2-tuples.
- The rendered UPDATE statement will emit the SET clause for each
- referenced column maintaining this order.
+ expected to receive parameters **only** via the
+ :meth:`.Update.values` method, and they must be passed as a Python
+ ``list`` of 2-tuples. The rendered UPDATE statement will emit the SET
+ clause for each referenced column maintaining this order.
.. versionadded:: 1.0.10
.. seealso::
:ref:`updates_order_parameters` - full example of the
- :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order` flag
+ :paramref:`~.update.preserve_parameter_order` flag
If both ``values`` and compile-time bind parameters are present, the
compile-time bind parameters override the information specified
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index e857f2da8..858695719 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -12,18 +12,25 @@
from __future__ import unicode_literals
-from .. import util, exc, inspection
-from . import type_api
-from . import operators
-from .visitors import Visitable, cloned_traverse, traverse
-from .annotation import Annotated
import itertools
-from .base import Executable, PARSE_AUTOCOMMIT, Immutable, NO_ARG
-from .base import _generative
import numbers
-
-import re
import operator
+import re
+
+from . import operators
+from . import type_api
+from .annotation import Annotated
+from .base import _generative
+from .base import Executable
+from .base import Immutable
+from .base import NO_ARG
+from .base import PARSE_AUTOCOMMIT
+from .visitors import cloned_traverse
+from .visitors import traverse
+from .visitors import Visitable
+from .. import exc
+from .. import inspection
+from .. import util
def _clone(element, **kw):
@@ -450,7 +457,9 @@ class ClauseElement(Visitable):
if util.py3k:
return str(self.compile())
else:
- return unicode(self.compile()).encode("ascii", "backslashreplace")
+ return unicode(self.compile()).encode( # noqa
+ "ascii", "backslashreplace"
+ ) # noqa
def __and__(self, other):
"""'and' at the ClauseElement level.
@@ -1244,8 +1253,8 @@ class TypeClause(ClauseElement):
__visit_name__ = "typeclause"
- def __init__(self, type):
- self.type = type
+ def __init__(self, type_):
+ self.type = type_
class TextClause(Executable, ClauseElement):
@@ -1609,10 +1618,10 @@ class TextClause(Executable, ClauseElement):
for id, name, timestamp in connection.execute(stmt):
print(id, name, timestamp)
- The positional form of :meth:`.TextClause.columns` also provides
- the unique feature of **positional column targeting**, which is
- particularly useful when using the ORM with complex textual queries.
- If we specify the columns from our model to :meth:`.TextClause.columns`,
+ The positional form of :meth:`.TextClause.columns` also provides the
+ unique feature of **positional column targeting**, which is
+ particularly useful when using the ORM with complex textual queries. If
+ we specify the columns from our model to :meth:`.TextClause.columns`,
the result set will match to those columns positionally, meaning the
name or origin of the column in the textual SQL doesn't matter::
@@ -2382,7 +2391,7 @@ class Cast(ColumnElement):
__visit_name__ = "cast"
def __init__(self, expression, type_):
- """Produce a ``CAST`` expression.
+ r"""Produce a ``CAST`` expression.
:func:`.cast` returns an instance of :class:`.Cast`.
@@ -2421,7 +2430,7 @@ class Cast(ColumnElement):
expression or a Python string which will be coerced into a bound
literal value.
- :param type_: A :class:`.TypeEngine` class or instance indicating
+ :param type\_: A :class:`.TypeEngine` class or instance indicating
the type to which the ``CAST`` should apply.
.. seealso::
@@ -2465,7 +2474,7 @@ class TypeCoerce(ColumnElement):
__visit_name__ = "type_coerce"
def __init__(self, expression, type_):
- """Associate a SQL expression with a particular type, without rendering
+ r"""Associate a SQL expression with a particular type, without rendering
``CAST``.
E.g.::
@@ -2517,7 +2526,7 @@ class TypeCoerce(ColumnElement):
expression or a Python string which will be coerced into a bound
literal value.
- :param type_: A :class:`.TypeEngine` class or instance indicating
+ :param type\_: A :class:`.TypeEngine` class or instance indicating
the type to which the expression is coerced.
.. seealso::
@@ -3234,7 +3243,7 @@ class Over(ColumnElement):
def __init__(
self, element, partition_by=None, order_by=None, range_=None, rows=None
):
- """Produce an :class:`.Over` object against a function.
+ r"""Produce an :class:`.Over` object against a function.
Used against aggregate or so-called "window" functions,
for database backends that support window functions.
@@ -3253,11 +3262,13 @@ class Over(ColumnElement):
mutually-exclusive parameters each accept a 2-tuple, which contains
a combination of integers and None::
- func.row_number().over(order_by=my_table.c.some_column, range_=(None, 0))
+ func.row_number().over(
+ order_by=my_table.c.some_column, range_=(None, 0))
The above would produce::
- ROW_NUMBER() OVER(ORDER BY some_column RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ ROW_NUMBER() OVER(ORDER BY some_column
+ RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
A value of None indicates "unbounded", a
value of zero indicates "current row", and negative / positive
@@ -3290,7 +3301,7 @@ class Over(ColumnElement):
:param order_by: a column element or string, or a list
of such, that will be used as the ORDER BY clause
of the OVER construct.
- :param range_: optional range clause for the window. This is a
+ :param range\_: optional range clause for the window. This is a
tuple value which can contain integer values or None, and will
render a RANGE BETWEEN PRECEDING / FOLLOWING clause
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index aab9f46d4..d8e5f170a 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -81,80 +81,98 @@ __all__ = [
]
-from .visitors import Visitable
-from .functions import func, modifier, FunctionElement, Function
-from ..util.langhelpers import public_factory
-from .elements import (
- ClauseElement,
- ColumnElement,
- BindParameter,
- CollectionAggregate,
- UnaryExpression,
- BooleanClauseList,
- Label,
- Cast,
- Case,
- ColumnClause,
- TextClause,
- Over,
- Null,
- True_,
- False_,
- BinaryExpression,
- Tuple,
- TypeClause,
- Extract,
- Grouping,
- WithinGroup,
- not_,
- quoted_name,
- collate,
- literal_column,
- between,
- literal,
- outparam,
- TypeCoerce,
- ClauseList,
- FunctionFilter,
-)
-
-from .elements import (
- SavepointClause,
- RollbackToSavepointClause,
- ReleaseSavepointClause,
-)
-
-from .base import ColumnCollection, Generative, Executable, PARSE_AUTOCOMMIT
-
-from .selectable import (
- Alias,
- Join,
- Select,
- Selectable,
- TableClause,
- CompoundSelect,
- CTE,
- FromClause,
- FromGrouping,
- Lateral,
- SelectBase,
- alias,
- GenerativeSelect,
- subquery,
- HasCTE,
- HasPrefixes,
- HasSuffixes,
- lateral,
- Exists,
- ScalarSelect,
- TextAsFrom,
- TableSample,
- tablesample,
-)
+from .base import _from_objects # noqa
+from .base import ColumnCollection # noqa
+from .base import Executable # noqa
+from .base import Generative # noqa
+from .base import PARSE_AUTOCOMMIT # noqa
+from .dml import Delete # noqa
+from .dml import Insert # noqa
+from .dml import Update # noqa
+from .dml import UpdateBase # noqa
+from .dml import ValuesBase # noqa
+from .elements import _clause_element_as_expr # noqa
+from .elements import _clone # noqa
+from .elements import _cloned_difference # noqa
+from .elements import _cloned_intersection # noqa
+from .elements import _column_as_key # noqa
+from .elements import _corresponding_column_or_error # noqa
+from .elements import _expression_literal_as_text # noqa
+from .elements import _is_column # noqa
+from .elements import _labeled # noqa
+from .elements import _literal_as_binds # noqa
+from .elements import _literal_as_label_reference # noqa
+from .elements import _literal_as_text # noqa
+from .elements import _only_column_elements # noqa
+from .elements import _select_iterables # noqa
+from .elements import _string_or_unprintable # noqa
+from .elements import _truncated_label # noqa
+from .elements import between # noqa
+from .elements import BinaryExpression # noqa
+from .elements import BindParameter # noqa
+from .elements import BooleanClauseList # noqa
+from .elements import Case # noqa
+from .elements import Cast # noqa
+from .elements import ClauseElement # noqa
+from .elements import ClauseList # noqa
+from .elements import collate # noqa
+from .elements import CollectionAggregate # noqa
+from .elements import ColumnClause # noqa
+from .elements import ColumnElement # noqa
+from .elements import Extract # noqa
+from .elements import False_ # noqa
+from .elements import FunctionFilter # noqa
+from .elements import Grouping # noqa
+from .elements import Label # noqa
+from .elements import literal # noqa
+from .elements import literal_column # noqa
+from .elements import not_ # noqa
+from .elements import Null # noqa
+from .elements import outparam # noqa
+from .elements import Over # noqa
+from .elements import quoted_name # noqa
+from .elements import ReleaseSavepointClause # noqa
+from .elements import RollbackToSavepointClause # noqa
+from .elements import SavepointClause # noqa
+from .elements import TextClause # noqa
+from .elements import True_ # noqa
+from .elements import Tuple # noqa
+from .elements import TypeClause # noqa
+from .elements import TypeCoerce # noqa
+from .elements import UnaryExpression # noqa
+from .elements import WithinGroup # noqa
+from .functions import func # noqa
+from .functions import Function # noqa
+from .functions import FunctionElement # noqa
+from .functions import modifier # noqa
+from .selectable import _interpret_as_from # noqa
+from .selectable import Alias # noqa
+from .selectable import alias # noqa
+from .selectable import CompoundSelect # noqa
+from .selectable import CTE # noqa
+from .selectable import Exists # noqa
+from .selectable import FromClause # noqa
+from .selectable import FromGrouping # noqa
+from .selectable import GenerativeSelect # noqa
+from .selectable import HasCTE # noqa
+from .selectable import HasPrefixes # noqa
+from .selectable import HasSuffixes # noqa
+from .selectable import Join # noqa
+from .selectable import Lateral # noqa
+from .selectable import lateral # noqa
+from .selectable import ScalarSelect # noqa
+from .selectable import Select # noqa
+from .selectable import Selectable # noqa
+from .selectable import SelectBase # noqa
+from .selectable import subquery # noqa
+from .selectable import TableClause # noqa
+from .selectable import TableSample # noqa
+from .selectable import tablesample # noqa
+from .selectable import TextAsFrom # noqa
+from .visitors import Visitable # noqa
+from ..util.langhelpers import public_factory # noqa
-from .dml import Insert, Update, Delete, UpdateBase, ValuesBase
-
# factory functions - these pull class-bound constructors and classmethods
# from SQL elements and selectables into public functions. This allows
# the functions to be available in the sqlalchemy.sql.* namespace and
@@ -174,7 +192,7 @@ within_group = public_factory(WithinGroup, ".expression.within_group")
label = public_factory(Label, ".expression.label")
case = public_factory(Case, ".expression.case")
cast = public_factory(Cast, ".expression.cast")
-extract = public_factory(Extract, ".expression.extract")
+extract = public_factory(Extract, ".exp # noqaression.extract")
tuple_ = public_factory(Tuple, ".expression.tuple_")
except_ = public_factory(CompoundSelect._create_except, ".expression.except_")
except_all = public_factory(
@@ -216,26 +234,6 @@ funcfilter = public_factory(FunctionFilter, ".expression.funcfilter")
# internal functions still being called from tests and the ORM,
# these might be better off in some other namespace
-from .base import _from_objects
-from .elements import (
- _literal_as_text,
- _clause_element_as_expr,
- _is_column,
- _labeled,
- _only_column_elements,
- _string_or_unprintable,
- _truncated_label,
- _clone,
- _cloned_difference,
- _cloned_intersection,
- _column_as_key,
- _literal_as_binds,
- _select_iterables,
- _corresponding_column_or_error,
- _literal_as_label_reference,
- _expression_literal_as_text,
-)
-from .selectable import _interpret_as_from
# old names for compatibility
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index 883bb8cc3..e191cff15 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -8,30 +8,33 @@
"""SQL function API, factories, and built-in functions.
"""
-from . import sqltypes, schema
-from .base import Executable, ColumnCollection
-from .elements import (
- ClauseList,
- Cast,
- Extract,
- _literal_as_binds,
- literal_column,
- _type_from_args,
- ColumnElement,
- _clone,
- Over,
- BindParameter,
- FunctionFilter,
- Grouping,
- WithinGroup,
- BinaryExpression,
-)
-from .selectable import FromClause, Select, Alias
-from . import util as sqlutil
+from . import annotation
from . import operators
+from . import schema
+from . import sqltypes
+from . import util as sqlutil
+from .base import ColumnCollection
+from .base import Executable
+from .elements import _clone
+from .elements import _literal_as_binds
+from .elements import _type_from_args
+from .elements import BinaryExpression
+from .elements import BindParameter
+from .elements import Cast
+from .elements import ClauseList
+from .elements import ColumnElement
+from .elements import Extract
+from .elements import FunctionFilter
+from .elements import Grouping
+from .elements import literal_column
+from .elements import Over
+from .elements import WithinGroup
+from .selectable import Alias
+from .selectable import FromClause
+from .selectable import Select
from .visitors import VisitableType
from .. import util
-from . import annotation
+
_registry = util.defaultdict(dict)
@@ -718,19 +721,19 @@ class coalesce(ReturnTypeFromArgs):
_has_args = True
-class max(ReturnTypeFromArgs):
+class max(ReturnTypeFromArgs): # noqa
pass
-class min(ReturnTypeFromArgs):
+class min(ReturnTypeFromArgs): # noqa
pass
-class sum(ReturnTypeFromArgs):
+class sum(ReturnTypeFromArgs): # noqa
pass
-class now(GenericFunction):
+class now(GenericFunction): # noqa
type = sqltypes.DateTime
@@ -813,7 +816,8 @@ class array_agg(GenericFunction):
.. seealso::
:func:`.postgresql.array_agg` - PostgreSQL-specific version that
- returns :class:`.postgresql.ARRAY`, which has PG-specific operators added.
+ returns :class:`.postgresql.ARRAY`, which has PG-specific operators
+ added.
"""
diff --git a/lib/sqlalchemy/sql/naming.py b/lib/sqlalchemy/sql/naming.py
index 144cc4dfc..ec6bc6a3b 100644
--- a/lib/sqlalchemy/sql/naming.py
+++ b/lib/sqlalchemy/sql/naming.py
@@ -10,21 +10,23 @@
"""
-from .schema import (
- Constraint,
- ForeignKeyConstraint,
- PrimaryKeyConstraint,
- UniqueConstraint,
- CheckConstraint,
- Index,
- Table,
- Column,
-)
-from .. import event, events
-from .. import exc
-from .elements import _truncated_label, _defer_name, _defer_none_name, conv
import re
+from .elements import _defer_name
+from .elements import _defer_none_name
+from .elements import conv
+from .schema import CheckConstraint
+from .schema import Column
+from .schema import Constraint
+from .schema import ForeignKeyConstraint
+from .schema import Index
+from .schema import PrimaryKeyConstraint
+from .schema import Table
+from .schema import UniqueConstraint
+from .. import event
+from .. import events # noqa
+from .. import exc
+
class ConventionDict(object):
def __init__(self, const, table, convention):
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py
index 2b843d751..379e7337f 100644
--- a/lib/sqlalchemy/sql/operators.py
+++ b/lib/sqlalchemy/sql/operators.py
@@ -10,29 +10,28 @@
"""Defines operators used in SQL expressions."""
+from operator import add
+from operator import and_
+from operator import contains
+from operator import eq
+from operator import ge
+from operator import getitem
+from operator import gt
+from operator import inv
+from operator import le
+from operator import lshift
+from operator import lt
+from operator import mod
+from operator import mul
+from operator import ne
+from operator import neg
+from operator import or_
+from operator import rshift
+from operator import sub
+from operator import truediv
+
from .. import util
-from operator import (
- and_,
- or_,
- inv,
- add,
- mul,
- sub,
- mod,
- truediv,
- lt,
- le,
- ne,
- gt,
- ge,
- eq,
- neg,
- getitem,
- lshift,
- rshift,
- contains,
-)
if util.py2k:
from operator import div
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py
index d6c3f5000..804c8bdb8 100644
--- a/lib/sqlalchemy/sql/schema.py
+++ b/lib/sqlalchemy/sql/schema.py
@@ -30,25 +30,30 @@ as components in SQL expressions.
"""
from __future__ import absolute_import
-from .. import exc, util, event, inspection
-from .base import SchemaEventTarget, DialectKWArgs
-import operator
-from . import visitors
-from . import type_api
-from .base import _bind_or_error, ColumnCollection
-from .elements import (
- ClauseElement,
- ColumnClause,
- _as_truncated,
- TextClause,
- _literal_as_text,
- ColumnElement,
- quoted_name,
-)
-from .selectable import TableClause
import collections
+import operator
+
import sqlalchemy
from . import ddl
+from . import type_api
+from . import visitors
+from .base import _bind_or_error
+from .base import ColumnCollection
+from .base import DialectKWArgs
+from .base import SchemaEventTarget
+from .elements import _as_truncated
+from .elements import _literal_as_text
+from .elements import ClauseElement
+from .elements import ColumnClause
+from .elements import ColumnElement
+from .elements import quoted_name
+from .elements import TextClause
+from .selectable import TableClause
+from .. import event
+from .. import exc
+from .. import inspection
+from .. import util
+
RETAIN_SCHEMA = util.symbol("retain_schema")
@@ -373,11 +378,11 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
the table resides in a schema other than the default selected schema
for the engine's database connection. Defaults to ``None``.
- If the owning :class:`.MetaData` of this :class:`.Table` specifies
- its own :paramref:`.MetaData.schema` parameter, then that schema
- name will be applied to this :class:`.Table` if the schema parameter
- here is set to ``None``. To set a blank schema name on a :class:`.Table`
- that would otherwise use the schema set on the owning :class:`.MetaData`,
+ If the owning :class:`.MetaData` of this :class:`.Table` specifies its
+ own :paramref:`.MetaData.schema` parameter, then that schema name will
+ be applied to this :class:`.Table` if the schema parameter here is set
+ to ``None``. To set a blank schema name on a :class:`.Table` that
+ would otherwise use the schema set on the owning :class:`.MetaData`,
specify the special symbol :attr:`.BLANK_SCHEMA`.
.. versionadded:: 1.0.14 Added the :attr:`.BLANK_SCHEMA` symbol to
@@ -386,10 +391,9 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
The quoting rules for the schema name are the same as those for the
``name`` parameter, in that quoting is applied for reserved words or
- case-sensitive names; to enable unconditional quoting for the
- schema name, specify the flag
- ``quote_schema=True`` to the constructor, or use the
- :class:`.quoted_name` construct to specify the name.
+ case-sensitive names; to enable unconditional quoting for the schema
+ name, specify the flag ``quote_schema=True`` to the constructor, or use
+ the :class:`.quoted_name` construct to specify the name.
:param useexisting: Deprecated. Use :paramref:`.Table.extend_existing`.
@@ -1070,9 +1074,9 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause):
Column('id', ForeignKey('other.id'),
primary_key=True, autoincrement='ignore_fk')
- It is typically not desirable to have "autoincrement" enabled
- on a column that refers to another via foreign key, as such a column
- is required to refer to a value that originates from elsewhere.
+ It is typically not desirable to have "autoincrement" enabled on a
+ column that refers to another via foreign key, as such a column is
+ required to refer to a value that originates from elsewhere.
The setting has these two effects on columns that meet the
above criteria:
@@ -4021,8 +4025,8 @@ class MetaData(SchemaItem):
To resolve these cycles, either the
:paramref:`.ForeignKeyConstraint.use_alter` parameter may be appled
to those constraints, or use the
- :func:`.schema.sort_tables_and_constraints` function which will break
- out foreign key constraints involved in cycles separately.
+ :func:`.schema.sort_tables_and_constraints` function which will
+ break out foreign key constraints involved in cycles separately.
.. seealso::
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index 1f1800514..beba1d242 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -10,50 +10,45 @@ SQL tables and derived rowsets.
"""
-from .elements import (
- ClauseElement,
- TextClause,
- ClauseList,
- and_,
- Grouping,
- UnaryExpression,
- literal_column,
- BindParameter,
-)
-from .elements import (
- _clone,
- _literal_as_text,
- _interpret_as_column_or_from,
- _expand_cloned,
- _select_iterables,
- _anonymous_label,
- _clause_element_as_expr,
- _cloned_intersection,
- _cloned_difference,
- True_,
- _literal_as_label_reference,
- _literal_and_labels_as_label_reference,
-)
-from .base import (
- Immutable,
- Executable,
- _generative,
- ColumnCollection,
- ColumnSet,
- _from_objects,
- Generative,
-)
-from . import type_api
-from .. import inspection
-from .. import util
-from .. import exc
-from operator import attrgetter
-from . import operators
-import operator
import collections
-from .annotation import Annotated
import itertools
+import operator
+from operator import attrgetter
+
from sqlalchemy.sql.visitors import Visitable
+from . import operators
+from . import type_api
+from .annotation import Annotated
+from .base import _from_objects
+from .base import _generative
+from .base import ColumnCollection
+from .base import ColumnSet
+from .base import Executable
+from .base import Generative
+from .base import Immutable
+from .elements import _anonymous_label
+from .elements import _clause_element_as_expr
+from .elements import _clone
+from .elements import _cloned_difference
+from .elements import _cloned_intersection
+from .elements import _expand_cloned
+from .elements import _interpret_as_column_or_from
+from .elements import _literal_and_labels_as_label_reference
+from .elements import _literal_as_label_reference
+from .elements import _literal_as_text
+from .elements import _select_iterables
+from .elements import and_
+from .elements import BindParameter
+from .elements import ClauseElement
+from .elements import ClauseList
+from .elements import Grouping
+from .elements import literal_column
+from .elements import TextClause
+from .elements import True_
+from .elements import UnaryExpression
+from .. import exc
+from .. import inspection
+from .. import util
def _interpret_as_from(element):
@@ -1013,15 +1008,15 @@ class Join(FromClause):
to join, or no way to join, an error is raised.
:param ignore_nonexistent_tables: Deprecated - this
- flag is no longer used. Only resolution errors regarding
- the two given tables are propagated.
+ flag is no longer used. Only resolution errors regarding
+ the two given tables are propagated.
:param a_subset: An optional expression that is a sub-component
- of ``a``. An attempt will be made to join to just this sub-component
- first before looking at the full ``a`` construct, and if found
- will be successful even if there are other ways to join to ``a``.
- This allows the "right side" of a join to be passed thereby
- providing a "natural join".
+ of ``a``. An attempt will be made to join to just this sub-component
+ first before looking at the full ``a`` construct, and if found
+ will be successful even if there are other ways to join to ``a``.
+ This allows the "right side" of a join to be passed thereby
+ providing a "natural join".
"""
constraints = cls._joincond_scan_left_right(
@@ -1441,8 +1436,8 @@ class TableSample(Alias):
"""Represent a TABLESAMPLE clause.
This object is constructed from the :func:`~.expression.tablesample` module
- level function as well as the :meth:`.FromClause.tablesample` method available
- on all :class:`.FromClause` subclasses.
+ level function as well as the :meth:`.FromClause.tablesample` method
+ available on all :class:`.FromClause` subclasses.
.. versionadded:: 1.1
@@ -2813,8 +2808,8 @@ class Select(HasPrefixes, HasSuffixes, GenerativeSelect):
a numerical value which usually renders as a ``LIMIT``
expression in the resulting select. Backends that don't
support ``LIMIT`` will attempt to provide similar
- functionality. This parameter is typically specified more naturally
- using the :meth:`.Select.limit` method on an existing
+ functionality. This parameter is typically specified more
+ naturally using the :meth:`.Select.limit` method on an existing
:class:`.Select`.
.. seealso::
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py
index 61fc6d3c9..65527645b 100644
--- a/lib/sqlalchemy/sql/sqltypes.py
+++ b/lib/sqlalchemy/sql/sqltypes.py
@@ -9,35 +9,35 @@
"""
-import datetime as dt
import codecs
-import collections
+import datetime as dt
+import decimal
import json
from . import elements
-from .type_api import (
- TypeEngine,
- TypeDecorator,
- to_instance,
- Variant,
- Emulated,
- NativeForEmulated,
-)
-from .elements import (
- quoted_name,
- TypeCoerce as type_coerce,
- _defer_name,
- Slice,
- _literal_as_binds,
-)
-from .. import exc, util, processors
-from .base import _bind_or_error, SchemaEventTarget
from . import operators
-from .. import inspection
+from . import type_api
+from .base import _bind_or_error
+from .base import SchemaEventTarget
+from .elements import _defer_name
+from .elements import _literal_as_binds
+from .elements import quoted_name
+from .elements import Slice
+from .elements import TypeCoerce as type_coerce # noqa
+from .type_api import Emulated
+from .type_api import NativeForEmulated # noqa
+from .type_api import to_instance
+from .type_api import TypeDecorator
+from .type_api import TypeEngine
+from .type_api import Variant
from .. import event
-from ..util import pickle
+from .. import exc
+from .. import inspection
+from .. import processors
+from .. import util
from ..util import compat
-import decimal
+from ..util import pickle
+
if util.jython:
import array
@@ -109,9 +109,11 @@ class Indexable(object):
raise NotImplementedError()
def __getitem__(self, index):
- adjusted_op, adjusted_right_expr, result_type = self._setup_getitem(
- index
- )
+ (
+ adjusted_op,
+ adjusted_right_expr,
+ result_type,
+ ) = self._setup_getitem(index)
return self.operate(
adjusted_op, adjusted_right_expr, result_type=result_type
)
@@ -1661,8 +1663,8 @@ class Boolean(Emulated, TypeEngine, SchemaType):
"""A bool datatype.
- :class:`.Boolean` typically uses BOOLEAN or SMALLINT on the DDL side, and on
- the Python side deals in ``True`` or ``False``.
+ :class:`.Boolean` typically uses BOOLEAN or SMALLINT on the DDL side,
+ and on the Python side deals in ``True`` or ``False``.
The :class:`.Boolean` datatype currently has two levels of assertion
that the values persisted are simple true/false values. For all
@@ -1938,16 +1940,17 @@ class JSON(Indexable, TypeEngine):
just the basic type.
Index operations return an expression object whose type defaults to
- :class:`.JSON` by default, so that further JSON-oriented instructions
- may be called upon the result type. Note that there are backend-specific
- idiosyncracies here, including that the PostgreSQL database does not generally
- compare a "json" to a "json" structure without type casts. These idiosyncracies
- can be accommodated in a backend-neutral way by making explicit use
- of the :func:`.cast` and :func:`.type_coerce` constructs.
- Comparison of specific index elements of a :class:`.JSON` object
- to other objects works best if the **left hand side is CAST to a string**
- and the **right hand side is rendered as a JSON string**; a future SQLAlchemy
- feature such as a generic "astext" modifier may simplify this at some point:
+ :class:`.JSON` by default, so that further JSON-oriented instructions may
+ be called upon the result type. Note that there are backend-specific
+ idiosyncracies here, including that the PostgreSQL database does not
+ generally compare a "json" to a "json" structure without type casts. These
+ idiosyncracies can be accommodated in a backend-neutral way by making
+ explicit use of the :func:`.cast` and :func:`.type_coerce` constructs.
+ Comparison of specific index elements of a :class:`.JSON` object to other
+ objects works best if the **left hand side is CAST to a string** and the
+ **right hand side is rendered as a JSON string**; a future SQLAlchemy
+ feature such as a generic "astext" modifier may simplify this at some
+ point:
* **Compare an element of a JSON structure to a string**::
@@ -1973,9 +1976,9 @@ class JSON(Indexable, TypeEngine):
data_table.c.data['some_key'], String
) == type_coerce(55, JSON)
- * **Compare an element of a JSON structure to some other JSON structure** - note
- that Python dictionaries are typically not ordered so care should be taken
- here to assert that the JSON structures are identical::
+ * **Compare an element of a JSON structure to some other JSON structure**
+ - note that Python dictionaries are typically not ordered so care should
+ be taken here to assert that the JSON structures are identical::
from sqlalchemy import cast, type_coerce
from sqlalchemy import String, JSON
@@ -2050,8 +2053,11 @@ class JSON(Indexable, TypeEngine):
from sqlalchemy import null
from sqlalchemy.dialects.postgresql import JSON
- obj1 = MyObject(json_value=null()) # will *always* insert SQL NULL
- obj2 = MyObject(json_value=JSON.NULL) # will *always* insert JSON string "null"
+ # will *always* insert SQL NULL
+ obj1 = MyObject(json_value=null())
+
+ # will *always* insert JSON string "null"
+ obj2 = MyObject(json_value=JSON.NULL)
session.add_all([obj1, obj2])
session.commit()
@@ -2089,8 +2095,8 @@ class JSON(Indexable, TypeEngine):
:paramref:`.JSON.none_as_null` does **not** apply to the
values passed to :paramref:`.Column.default` and
- :paramref:`.Column.server_default`; a value of ``None`` passed for
- these parameters means "no default present".
+ :paramref:`.Column.server_default`; a value of ``None``
+ passed for these parameters means "no default present".
.. seealso::
@@ -2238,11 +2244,11 @@ class ARRAY(SchemaEventTarget, Indexable, Concatenable, TypeEngine):
with PostgreSQL, as it provides additional operators specific
to that backend.
- :class:`.types.ARRAY` is part of the Core in support of various SQL standard
- functions such as :class:`.array_agg` which explicitly involve arrays;
- however, with the exception of the PostgreSQL backend and possibly
- some third-party dialects, no other SQLAlchemy built-in dialect has
- support for this type.
+ :class:`.types.ARRAY` is part of the Core in support of various SQL
+ standard functions such as :class:`.array_agg` which explicitly involve
+ arrays; however, with the exception of the PostgreSQL backend and possibly
+ some third-party dialects, no other SQLAlchemy built-in dialect has support
+ for this type.
An :class:`.types.ARRAY` type is constructed given the "type"
of element::
@@ -2284,8 +2290,8 @@ class ARRAY(SchemaEventTarget, Indexable, Concatenable, TypeEngine):
serves to define the kind of type that the ``[]`` operator should
return, e.g. for an ARRAY of INTEGER with two dimensions::
- >>> expr = table.c.column[5] # returns ARRAY(Integer, dimensions=1)
- >>> expr = expr[6] # returns Integer
+ >>> expr = table.c.column[5] # returns ARRAY(Integer, dimensions=1)
+ >>> expr = expr[6] # returns Integer
For 1-dimensional arrays, an :class:`.types.ARRAY` instance with no
dimension parameter will generally assume single-dimensional behaviors.
@@ -2308,9 +2314,9 @@ class ARRAY(SchemaEventTarget, Indexable, Concatenable, TypeEngine):
})
The :class:`.types.ARRAY` type also provides for the operators
- :meth:`.types.ARRAY.Comparator.any` and :meth:`.types.ARRAY.Comparator.all`.
- The PostgreSQL-specific version of :class:`.types.ARRAY` also provides additional
- operators.
+ :meth:`.types.ARRAY.Comparator.any` and
+ :meth:`.types.ARRAY.Comparator.all`. The PostgreSQL-specific version of
+ :class:`.types.ARRAY` also provides additional operators.
.. versionadded:: 1.1.0
@@ -2780,10 +2786,10 @@ _type_map = {
}
if util.py3k:
- _type_map[bytes] = LargeBinary()
+ _type_map[bytes] = LargeBinary() # noqa
_type_map[str] = Unicode()
else:
- _type_map[unicode] = Unicode()
+ _type_map[unicode] = Unicode() # noqa
_type_map[str] = String()
_type_map_get = _type_map.get
@@ -2811,8 +2817,6 @@ def _resolve_value_to_type(value):
# back-assign to type_api
-from . import type_api
-
type_api.BOOLEANTYPE = BOOLEANTYPE
type_api.STRINGTYPE = STRINGTYPE
type_api.INTEGERTYPE = INTEGERTYPE
diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py
index 7fe780783..647c3e776 100644
--- a/lib/sqlalchemy/sql/type_api.py
+++ b/lib/sqlalchemy/sql/type_api.py
@@ -10,10 +10,13 @@
"""
-from .. import exc, util
from . import operators
-from .visitors import Visitable, VisitableType
from .base import SchemaEventTarget
+from .visitors import Visitable
+from .visitors import VisitableType
+from .. import exc
+from .. import util
+
# these are back-assigned by sqltypes.
BOOLEANTYPE = None
@@ -396,7 +399,7 @@ class TypeEngine(Visitable):
raise NotImplementedError()
def with_variant(self, type_, dialect_name):
- """Produce a new type object that will utilize the given
+ r"""Produce a new type object that will utilize the given
type when applied to the dialect of the given name.
e.g.::
@@ -414,7 +417,7 @@ class TypeEngine(Visitable):
itself provides a :meth:`.Variant.with_variant`
that can be called repeatedly.
- :param type_: a :class:`.TypeEngine` that will be selected
+ :param type\_: a :class:`.TypeEngine` that will be selected
as a variant from the originating type, when a dialect
of the given name is in use.
:param dialect_name: base name of the dialect which uses
@@ -592,7 +595,9 @@ class TypeEngine(Visitable):
def __str__(self):
if util.py2k:
- return unicode(self.compile()).encode("ascii", "backslashreplace")
+ return unicode(self.compile()).encode( # noqa
+ "ascii", "backslashreplace"
+ ) # noqa
else:
return str(self.compile())
@@ -1407,11 +1412,11 @@ class Variant(TypeDecorator):
impl._set_parent_with_dispatch(parent)
def with_variant(self, type_, dialect_name):
- """Return a new :class:`.Variant` which adds the given
+ r"""Return a new :class:`.Variant` which adds the given
type + dialect name to the mapping, in addition to the
mapping present in this :class:`.Variant`.
- :param type_: a :class:`.TypeEngine` that will be selected
+ :param type\_: a :class:`.TypeEngine` that will be selected
as a variant from the originating type, when a dialect
of the given name is in use.
:param dialect_name: base name of the dialect which uses
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index 4feaf9938..604b3cfd9 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -9,41 +9,39 @@
"""
-from .. import exc, util
-from .base import _from_objects, ColumnSet
-from . import operators, visitors
-from itertools import chain
from collections import deque
+from itertools import chain
-from .elements import (
- BindParameter,
- ColumnClause,
- ColumnElement,
- Null,
- UnaryExpression,
- literal_column,
- Label,
- _label_reference,
- _textual_label_reference,
-)
-from .selectable import (
- SelectBase,
- ScalarSelect,
- Join,
- FromClause,
- FromGrouping,
-)
+from . import operators
+from . import visitors
+from .annotation import _deep_annotate # noqa
+from .annotation import _deep_deannotate # noqa
+from .annotation import _shallow_annotate # noqa
+from .base import _from_objects
+from .base import ColumnSet
+from .ddl import sort_tables # noqa
+from .elements import _find_columns # noqa
+from .elements import _label_reference
+from .elements import _textual_label_reference
+from .elements import BindParameter
+from .elements import ColumnClause
+from .elements import ColumnElement
+from .elements import Null
+from .elements import UnaryExpression
from .schema import Column
+from .selectable import FromClause
+from .selectable import FromGrouping
+from .selectable import Join
+from .selectable import ScalarSelect
+from .selectable import SelectBase
+from .. import exc
+from .. import util
+
join_condition = util.langhelpers.public_factory(
Join._join_condition, ".sql.util.join_condition"
)
-# names that are still being imported from the outside
-from .annotation import _shallow_annotate, _deep_annotate, _deep_deannotate
-from .elements import _find_columns
-from .ddl import sort_tables
-
def find_join_source(clauses, join_to):
"""Given a list of FROM clauses and a selectable,
diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py
index bf1743643..d4b72dd59 100644
--- a/lib/sqlalchemy/sql/visitors.py
+++ b/lib/sqlalchemy/sql/visitors.py
@@ -25,9 +25,11 @@ http://techspot.zzzeek.org/2008/01/23/expression-transformations/
"""
from collections import deque
-from .. import util
import operator
+
from .. import exc
+from .. import util
+
__all__ = [
"VisitableType",