]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Post black reformatting
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 6 Jan 2019 06:19:47 +0000 (01:19 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 6 Jan 2019 23:23:11 +0000 (18:23 -0500)
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

419 files changed:
examples/adjacency_list/adjacency_list.py
examples/association/basic_association.py
examples/association/dict_of_sets_with_default.py
examples/association/proxied_association.py
examples/custom_attributes/custom_management.py
examples/dogpile_caching/__init__.py
examples/dogpile_caching/advanced.py
examples/dogpile_caching/caching_query.py
examples/dogpile_caching/environment.py
examples/dogpile_caching/fixture_data.py
examples/dogpile_caching/helloworld.py
examples/dogpile_caching/local_session_caching.py
examples/dogpile_caching/model.py
examples/dogpile_caching/relationship_caching.py
examples/dynamic_dict/dynamic_dict.py
examples/elementtree/adjacency_list.py
examples/elementtree/optimized_al.py
examples/elementtree/pickle.py
examples/generic_associations/__init__.py
examples/generic_associations/discriminator_on_association.py
examples/generic_associations/generic_fk.py
examples/generic_associations/table_per_association.py
examples/generic_associations/table_per_related.py
examples/graphs/directed_graph.py
examples/inheritance/concrete.py
examples/inheritance/joined.py
examples/inheritance/single.py
examples/join_conditions/cast.py
examples/join_conditions/threeway.py
examples/large_collection/large_collection.py
examples/materialized_paths/materialized_paths.py
examples/nested_sets/nested_sets.py
examples/performance/__init__.py
examples/performance/__main__.py
examples/performance/bulk_inserts.py
examples/performance/bulk_updates.py
examples/performance/large_resultsets.py
examples/performance/short_selects.py
examples/performance/single_inserts.py
examples/postgis/__init__.py
examples/postgis/postgis.py
examples/sharding/__init__.py
examples/sharding/attribute_shard.py
examples/space_invaders/space_invaders.py
examples/versioned_history/__init__.py
examples/versioned_history/history_meta.py
examples/versioned_history/test_versioning.py
examples/versioned_rows/versioned_map.py
examples/versioned_rows/versioned_rows.py
examples/versioned_rows/versioned_rows_w_versionid.py
examples/versioned_rows/versioned_update_old_row.py
examples/vertical/dictlike-polymorphic.py
lib/sqlalchemy/__init__.py
lib/sqlalchemy/connectors/mxodbc.py
lib/sqlalchemy/connectors/pyodbc.py
lib/sqlalchemy/connectors/zxJDBC.py
lib/sqlalchemy/databases/__init__.py
lib/sqlalchemy/dialects/__init__.py
lib/sqlalchemy/dialects/firebird/__init__.py
lib/sqlalchemy/dialects/firebird/base.py
lib/sqlalchemy/dialects/firebird/fdb.py
lib/sqlalchemy/dialects/firebird/kinterbasdb.py
lib/sqlalchemy/dialects/mssql/__init__.py
lib/sqlalchemy/dialects/mssql/adodbapi.py
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/dialects/mssql/information_schema.py
lib/sqlalchemy/dialects/mssql/mxodbc.py
lib/sqlalchemy/dialects/mssql/pymssql.py
lib/sqlalchemy/dialects/mssql/pyodbc.py
lib/sqlalchemy/dialects/mssql/zxjdbc.py
lib/sqlalchemy/dialects/mysql/__init__.py
lib/sqlalchemy/dialects/mysql/base.py
lib/sqlalchemy/dialects/mysql/cymysql.py
lib/sqlalchemy/dialects/mysql/dml.py
lib/sqlalchemy/dialects/mysql/enumerated.py
lib/sqlalchemy/dialects/mysql/gaerdbms.py
lib/sqlalchemy/dialects/mysql/json.py
lib/sqlalchemy/dialects/mysql/mysqlconnector.py
lib/sqlalchemy/dialects/mysql/mysqldb.py
lib/sqlalchemy/dialects/mysql/oursql.py
lib/sqlalchemy/dialects/mysql/pymysql.py
lib/sqlalchemy/dialects/mysql/pyodbc.py
lib/sqlalchemy/dialects/mysql/reflection.py
lib/sqlalchemy/dialects/mysql/types.py
lib/sqlalchemy/dialects/mysql/zxjdbc.py
lib/sqlalchemy/dialects/oracle/__init__.py
lib/sqlalchemy/dialects/oracle/base.py
lib/sqlalchemy/dialects/oracle/cx_oracle.py
lib/sqlalchemy/dialects/oracle/zxjdbc.py
lib/sqlalchemy/dialects/postgresql/__init__.py
lib/sqlalchemy/dialects/postgresql/array.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/dialects/postgresql/dml.py
lib/sqlalchemy/dialects/postgresql/ext.py
lib/sqlalchemy/dialects/postgresql/hstore.py
lib/sqlalchemy/dialects/postgresql/json.py
lib/sqlalchemy/dialects/postgresql/pg8000.py
lib/sqlalchemy/dialects/postgresql/psycopg2.py
lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py
lib/sqlalchemy/dialects/postgresql/pygresql.py
lib/sqlalchemy/dialects/postgresql/pypostgresql.py
lib/sqlalchemy/dialects/postgresql/ranges.py
lib/sqlalchemy/dialects/postgresql/zxjdbc.py
lib/sqlalchemy/dialects/sqlite/__init__.py
lib/sqlalchemy/dialects/sqlite/base.py
lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
lib/sqlalchemy/dialects/sqlite/pysqlite.py
lib/sqlalchemy/dialects/sybase/__init__.py
lib/sqlalchemy/dialects/sybase/base.py
lib/sqlalchemy/dialects/sybase/mxodbc.py
lib/sqlalchemy/dialects/sybase/pyodbc.py
lib/sqlalchemy/dialects/sybase/pysybase.py
lib/sqlalchemy/engine/__init__.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/engine/interfaces.py
lib/sqlalchemy/engine/reflection.py
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/engine/strategies.py
lib/sqlalchemy/engine/threadlocal.py
lib/sqlalchemy/engine/url.py
lib/sqlalchemy/engine/util.py
lib/sqlalchemy/event/__init__.py
lib/sqlalchemy/event/api.py
lib/sqlalchemy/event/attr.py
lib/sqlalchemy/event/base.py
lib/sqlalchemy/event/registry.py
lib/sqlalchemy/events.py
lib/sqlalchemy/exc.py
lib/sqlalchemy/ext/__init__.py
lib/sqlalchemy/ext/associationproxy.py
lib/sqlalchemy/ext/automap.py
lib/sqlalchemy/ext/baked.py
lib/sqlalchemy/ext/declarative/__init__.py
lib/sqlalchemy/ext/declarative/api.py
lib/sqlalchemy/ext/declarative/base.py
lib/sqlalchemy/ext/declarative/clsregistry.py
lib/sqlalchemy/ext/horizontal_shard.py
lib/sqlalchemy/ext/hybrid.py
lib/sqlalchemy/ext/indexable.py
lib/sqlalchemy/ext/instrumentation.py
lib/sqlalchemy/ext/mutable.py
lib/sqlalchemy/ext/orderinglist.py
lib/sqlalchemy/ext/serializer.py
lib/sqlalchemy/inspection.py
lib/sqlalchemy/interfaces.py
lib/sqlalchemy/log.py
lib/sqlalchemy/orm/__init__.py
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/orm/deprecated_interfaces.py
lib/sqlalchemy/orm/descriptor_props.py
lib/sqlalchemy/orm/dynamic.py
lib/sqlalchemy/orm/evaluator.py
lib/sqlalchemy/orm/events.py
lib/sqlalchemy/orm/exc.py
lib/sqlalchemy/orm/identity.py
lib/sqlalchemy/orm/instrumentation.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/loading.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/path_registry.py
lib/sqlalchemy/orm/persistence.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/relationships.py
lib/sqlalchemy/orm/scoping.py
lib/sqlalchemy/orm/session.py
lib/sqlalchemy/orm/state.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/orm/strategy_options.py
lib/sqlalchemy/orm/sync.py
lib/sqlalchemy/orm/unitofwork.py
lib/sqlalchemy/orm/util.py
lib/sqlalchemy/pool/__init__.py
lib/sqlalchemy/pool/base.py
lib/sqlalchemy/pool/dbapi_proxy.py
lib/sqlalchemy/pool/impl.py
lib/sqlalchemy/processors.py
lib/sqlalchemy/schema.py
lib/sqlalchemy/sql/__init__.py
lib/sqlalchemy/sql/annotation.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/crud.py
lib/sqlalchemy/sql/ddl.py
lib/sqlalchemy/sql/default_comparator.py
lib/sqlalchemy/sql/dml.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/expression.py
lib/sqlalchemy/sql/functions.py
lib/sqlalchemy/sql/naming.py
lib/sqlalchemy/sql/operators.py
lib/sqlalchemy/sql/schema.py
lib/sqlalchemy/sql/selectable.py
lib/sqlalchemy/sql/sqltypes.py
lib/sqlalchemy/sql/type_api.py
lib/sqlalchemy/sql/util.py
lib/sqlalchemy/sql/visitors.py
lib/sqlalchemy/testing/__init__.py
lib/sqlalchemy/testing/assertions.py
lib/sqlalchemy/testing/assertsql.py
lib/sqlalchemy/testing/engines.py
lib/sqlalchemy/testing/entities.py
lib/sqlalchemy/testing/exclusions.py
lib/sqlalchemy/testing/fixtures.py
lib/sqlalchemy/testing/mock.py
lib/sqlalchemy/testing/plugin/bootstrap.py
lib/sqlalchemy/testing/plugin/noseplugin.py
lib/sqlalchemy/testing/plugin/plugin_base.py
lib/sqlalchemy/testing/plugin/pytestplugin.py
lib/sqlalchemy/testing/profiling.py
lib/sqlalchemy/testing/provision.py
lib/sqlalchemy/testing/replay_fixture.py
lib/sqlalchemy/testing/requirements.py
lib/sqlalchemy/testing/runner.py
lib/sqlalchemy/testing/schema.py
lib/sqlalchemy/testing/suite/__init__.py
lib/sqlalchemy/testing/suite/test_cte.py
lib/sqlalchemy/testing/suite/test_ddl.py
lib/sqlalchemy/testing/suite/test_dialect.py
lib/sqlalchemy/testing/suite/test_insert.py
lib/sqlalchemy/testing/suite/test_reflection.py
lib/sqlalchemy/testing/suite/test_results.py
lib/sqlalchemy/testing/suite/test_select.py
lib/sqlalchemy/testing/suite/test_sequence.py
lib/sqlalchemy/testing/suite/test_types.py
lib/sqlalchemy/testing/suite/test_update_delete.py
lib/sqlalchemy/testing/util.py
lib/sqlalchemy/testing/warnings.py
lib/sqlalchemy/types.py
lib/sqlalchemy/util/__init__.py
lib/sqlalchemy/util/_collections.py
lib/sqlalchemy/util/compat.py
lib/sqlalchemy/util/deprecations.py
lib/sqlalchemy/util/langhelpers.py
lib/sqlalchemy/util/queue.py
lib/sqlalchemy/util/topological.py
reap_dbs.py
setup.py
sqla_nose.py
test/aaa_profiling/test_compiler.py
test/aaa_profiling/test_memusage.py
test/aaa_profiling/test_orm.py
test/aaa_profiling/test_pool.py
test/aaa_profiling/test_resultset.py
test/aaa_profiling/test_zoomark.py
test/aaa_profiling/test_zoomark_orm.py
test/base/test_dependency.py
test/base/test_events.py
test/base/test_except.py
test/base/test_inspect.py
test/base/test_tutorials.py
test/base/test_utils.py
test/conftest.py
test/dialect/mssql/test_compiler.py
test/dialect/mssql/test_engine.py
test/dialect/mssql/test_query.py
test/dialect/mssql/test_reflection.py
test/dialect/mssql/test_types.py
test/dialect/mysql/test_compiler.py
test/dialect/mysql/test_dialect.py
test/dialect/mysql/test_for_update.py
test/dialect/mysql/test_on_duplicate.py
test/dialect/mysql/test_query.py
test/dialect/mysql/test_reflection.py
test/dialect/mysql/test_types.py
test/dialect/oracle/test_compiler.py
test/dialect/oracle/test_dialect.py
test/dialect/oracle/test_reflection.py
test/dialect/oracle/test_types.py
test/dialect/postgresql/test_compiler.py
test/dialect/postgresql/test_dialect.py
test/dialect/postgresql/test_on_conflict.py
test/dialect/postgresql/test_query.py
test/dialect/postgresql/test_reflection.py
test/dialect/postgresql/test_types.py
test/dialect/test_all.py
test/dialect/test_firebird.py
test/dialect/test_mxodbc.py
test/dialect/test_pyodbc.py
test/dialect/test_sqlite.py
test/dialect/test_suite.py
test/dialect/test_sybase.py
test/engine/test_bind.py
test/engine/test_ddlevents.py
test/engine/test_execute.py
test/engine/test_logging.py
test/engine/test_parseconnect.py
test/engine/test_pool.py
test/engine/test_processors.py
test/engine/test_reconnect.py
test/engine/test_reflection.py
test/engine/test_transaction.py
test/ext/declarative/test_basic.py
test/ext/declarative/test_clsregistry.py
test/ext/declarative/test_inheritance.py
test/ext/declarative/test_mixin.py
test/ext/declarative/test_reflection.py
test/ext/test_associationproxy.py
test/ext/test_automap.py
test/ext/test_baked.py
test/ext/test_compiler.py
test/ext/test_extendedattr.py
test/ext/test_horizontal_shard.py
test/ext/test_hybrid.py
test/ext/test_indexable.py
test/ext/test_mutable.py
test/ext/test_orderinglist.py
test/ext/test_serializer.py
test/orm/_fixtures.py
test/orm/inheritance/_poly_fixtures.py
test/orm/inheritance/test_abc_inheritance.py
test/orm/inheritance/test_abc_polymorphic.py
test/orm/inheritance/test_assorted_poly.py
test/orm/inheritance/test_basic.py
test/orm/inheritance/test_concrete.py
test/orm/inheritance/test_manytomany.py
test/orm/inheritance/test_poly_linked_list.py
test/orm/inheritance/test_poly_loading.py
test/orm/inheritance/test_poly_persistence.py
test/orm/inheritance/test_polymorphic_rel.py
test/orm/inheritance/test_productspec.py
test/orm/inheritance/test_relationship.py
test/orm/inheritance/test_selects.py
test/orm/inheritance/test_single.py
test/orm/inheritance/test_with_poly.py
test/orm/test_association.py
test/orm/test_assorted_eager.py
test/orm/test_attributes.py
test/orm/test_backref_mutations.py
test/orm/test_bind.py
test/orm/test_bulk.py
test/orm/test_bundle.py
test/orm/test_cascade.py
test/orm/test_collection.py
test/orm/test_compile.py
test/orm/test_composites.py
test/orm/test_cycles.py
test/orm/test_default_strategies.py
test/orm/test_defaults.py
test/orm/test_deferred.py
test/orm/test_deprecations.py
test/orm/test_descriptor.py
test/orm/test_dynamic.py
test/orm/test_eager_relations.py
test/orm/test_evaluator.py
test/orm/test_events.py
test/orm/test_expire.py
test/orm/test_froms.py
test/orm/test_generative.py
test/orm/test_hasparent.py
test/orm/test_immediate_load.py
test/orm/test_inspect.py
test/orm/test_instrumentation.py
test/orm/test_joins.py
test/orm/test_lazy_relations.py
test/orm/test_load_on_fks.py
test/orm/test_loading.py
test/orm/test_lockmode.py
test/orm/test_manytomany.py
test/orm/test_mapper.py
test/orm/test_merge.py
test/orm/test_naturalpks.py
test/orm/test_of_type.py
test/orm/test_onetoone.py
test/orm/test_options.py
test/orm/test_pickled.py
test/orm/test_query.py
test/orm/test_rel_fn.py
test/orm/test_relationships.py
test/orm/test_scoping.py
test/orm/test_selectable.py
test/orm/test_selectin_relations.py
test/orm/test_session.py
test/orm/test_subquery_relations.py
test/orm/test_sync.py
test/orm/test_transaction.py
test/orm/test_unitofwork.py
test/orm/test_unitofworkv2.py
test/orm/test_update_delete.py
test/orm/test_utils.py
test/orm/test_validators.py
test/orm/test_versioning.py
test/perf/invalidate_stresstest.py
test/perf/orm2010.py
test/requirements.py
test/sql/test_case_statement.py
test/sql/test_compiler.py
test/sql/test_constraints.py
test/sql/test_cte.py
test/sql/test_ddlemit.py
test/sql/test_defaults.py
test/sql/test_delete.py
test/sql/test_functions.py
test/sql/test_generative.py
test/sql/test_insert.py
test/sql/test_insert_exec.py
test/sql/test_inspect.py
test/sql/test_join_rewriting.py
test/sql/test_labels.py
test/sql/test_lateral.py
test/sql/test_metadata.py
test/sql/test_operators.py
test/sql/test_query.py
test/sql/test_quote.py
test/sql/test_resultset.py
test/sql/test_returning.py
test/sql/test_rowcount.py
test/sql/test_selectable.py
test/sql/test_tablesample.py
test/sql/test_text.py
test/sql/test_type_expressions.py
test/sql/test_types.py
test/sql/test_unicode.py
test/sql/test_update.py
test/sql/test_utils.py

index f1628a6329f1823d96f499d905c18ecc587e2943..8cdd8854031b8627668f89e758992f5d7d3bcd82 100644 (file)
@@ -1,6 +1,13 @@
-from sqlalchemy import Column, ForeignKey, Integer, String, create_engine
-from sqlalchemy.orm import Session, relationship, backref, joinedload_all
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 from sqlalchemy.orm.collections import attribute_mapped_collection
 
 
index 52476f18425b9f187c042cd4673bb2cdfe3857ff..d2271ad430e30fe4e58dbee1697c4182b9d88382 100644 (file)
@@ -12,18 +12,18 @@ of "items", with a particular price paid associated with each "item".
 
 from datetime import datetime
 
-from sqlalchemy import (
-    create_engine,
-    Column,
-    Integer,
-    String,
-    DateTime,
-    Float,
-    ForeignKey,
-    and_,
-)
-from sqlalchemy.orm import relationship, Session
+from sqlalchemy import and_
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import DateTime
+from sqlalchemy import Float
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+
 
 Base = declarative_base()
 
index 7f668c0879f6166152234883f3e9496cbbc2d3e2..435761d3f7fde908d324e35b886a388b3562a634 100644 (file)
@@ -12,13 +12,19 @@ upon access of a non-existent key, in the same manner as Python's
 
 """
 
-from sqlalchemy import String, Integer, Column, create_engine, ForeignKey
-from sqlalchemy.orm import relationship, Session
-from sqlalchemy.orm.collections import MappedCollection
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.ext.associationproxy import association_proxy
 import operator
 
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.ext.associationproxy import association_proxy
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm.collections import MappedCollection
+
 
 class Base(object):
     id = Column(Integer, primary_key=True)
index 46785c6e25a450006c0455fde31954b640a02711..0ec8fa899ac990257288ca508cc463b7c45cb45e 100644 (file)
@@ -7,18 +7,18 @@ to ``OrderItem`` optional.
 
 from datetime import datetime
 
-from sqlalchemy import (
-    create_engine,
-    Column,
-    Integer,
-    String,
-    DateTime,
-    Float,
-    ForeignKey,
-)
-from sqlalchemy.orm import relationship, Session
-from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import DateTime
+from sqlalchemy import Float
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.ext.associationproxy import association_proxy
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+
 
 Base = declarative_base()
 
index 81238590602f82f80f5b9de1d527fae08a9756f0..6cddfe7bd114427da9c96c238447475f9ccbcdad 100644 (file)
@@ -9,25 +9,21 @@ descriptors with a user-defined system.
 
 
 """
-from sqlalchemy import (
-    create_engine,
-    MetaData,
-    Table,
-    Column,
-    Integer,
-    Text,
-    ForeignKey,
-)
-from sqlalchemy.orm import mapper, relationship, Session
-
-from sqlalchemy.orm.attributes import (
-    set_attribute,
-    get_attribute,
-    del_attribute,
-)
-from sqlalchemy.orm.instrumentation import is_instrumented
-
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Table
+from sqlalchemy import Text
 from sqlalchemy.ext.instrumentation import InstrumentationManager
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm.attributes import del_attribute
+from sqlalchemy.orm.attributes import get_attribute
+from sqlalchemy.orm.attributes import set_attribute
+from sqlalchemy.orm.instrumentation import is_instrumented
 
 
 class MyClassState(InstrumentationManager):
index 0f19854e9db7cd71f2fea7ae09729f5d0f653359..91105dc020e87bcaf0d32632a0a25da2dcf5f68e 100644 (file)
@@ -1,13 +1,8 @@
 """
-Illustrates how to embed `dogpile.cache <https://dogpilecache.readthedocs.io/>`_
-functionality within
-the :class:`.Query` object, allowing full cache control as well as the
-ability to pull "lazy loaded" attributes from long term cache
-as well.
-
-.. versionchanged:: 0.8 The example was modernized to use
-   dogpile.cache, replacing Beaker as the caching library in
-   use.
+Illustrates how to embed
+`dogpile.cache <https://dogpilecache.readthedocs.io/>`_
+functionality within the :class:`.Query` object, allowing full cache control
+as well as the ability to pull "lazy loaded" attributes from long term cache.
 
 In this demo, the following techniques are illustrated:
 
index 8f395bd7b374e20339448ce8769f942d505723aa..d2ef825562a058b64a41b3f907196281d1555f23 100644 (file)
@@ -3,9 +3,11 @@ including front-end loading, cache invalidation and collection caching.
 
 """
 
+from .caching_query import FromCache
+from .caching_query import RelationshipCache
 from .environment import Session
-from .model import Person, cache_address_bits
-from .caching_query import FromCache, RelationshipCache
+from .model import cache_address_bits
+from .model import Person
 
 
 def load_name_range(start, end, invalidate=False):
@@ -68,7 +70,8 @@ print(", ".join([p.name for p in load_name_range(25, 40, True)]))
 # illustrate the address loading from either cache/already
 # on the Person
 print(
-    "\n\nPeople plus addresses, two through twelve, addresses possibly from cache"
+    "\n\nPeople plus addresses, two through twelve, addresses "
+    "possibly from cache"
 )
 for p in load_name_range(2, 12):
     print(p.format_full())
index 060c146132caee6d25a9e54057a2ace6a2b55412..3d528b880de2aaad5a5ddbee687468a9c85fc85d 100644 (file)
@@ -17,9 +17,10 @@ The rest of what's here are standard SQLAlchemy and
 dogpile.cache constructs.
 
 """
+from dogpile.cache.api import NO_VALUE
+
 from sqlalchemy.orm.interfaces import MapperOption
 from sqlalchemy.orm.query import Query
-from dogpile.cache.api import NO_VALUE
 
 
 class CachingQuery(Query):
@@ -187,14 +188,14 @@ class FromCache(MapperOption):
         """Construct a new FromCache.
 
         :param region: the cache region.  Should be a
-        region configured in the dictionary of dogpile
-        regions.
+         region configured in the dictionary of dogpile
+         regions.
 
         :param cache_key: optional.  A string cache key
-        that will serve as the key to the query.   Use this
-        if your query has a huge amount of parameters (such
-        as when using in_()) which correspond more simply to
-        some other identifier.
+         that will serve as the key to the query.   Use this
+         if your query has a huge amount of parameters (such
+         as when using in_()) which correspond more simply to
+         some other identifier.
 
         """
         self.region = region
@@ -215,14 +216,14 @@ class RelationshipCache(MapperOption):
         """Construct a new RelationshipCache.
 
         :param attribute: A Class.attribute which
-        indicates a particular class relationship() whose
-        lazy loader should be pulled from the cache.
+         indicates a particular class relationship() whose
+         lazy loader should be pulled from the cache.
 
         :param region: name of the cache region.
 
         :param cache_key: optional.  A string cache key
-        that will serve as the key to the query, bypassing
-        the usual means of forming a key from the Query itself.
+         that will serve as the key to the query, bypassing
+         the usual means of forming a key from the Query itself.
 
         """
         self.region = region
index 13bd0a31002bce29ece08f42249aa3e67dbed383..723ee653d5e78f11fcc9e5e26ab54e23501b8828 100644 (file)
@@ -2,19 +2,23 @@
 bootstrap fixture data if necessary.
 
 """
-from . import caching_query
-from sqlalchemy import create_engine
-from sqlalchemy.orm import scoped_session, sessionmaker
-from sqlalchemy.ext.declarative import declarative_base
-from dogpile.cache.region import make_region
-import os
 from hashlib import md5
+import os
 import sys
 
+from dogpile.cache.region import make_region
+
+from sqlalchemy import create_engine
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import scoped_session
+from sqlalchemy.orm import sessionmaker
+from . import caching_query
+
+
 py2k = sys.version_info < (3, 0)
 
 if py2k:
-    input = raw_input
+    input = raw_input  # noqa
 
 # dogpile cache regions.  A home base for cache configurations.
 regions = {}
index e301db2a46bbc0e1be8f665138e21895c03a6740..8387a2cb275dd262aeb466dfc603972e84040d44 100644 (file)
@@ -1,12 +1,18 @@
-"""Installs some sample data.   Here we have a handful of postal codes for a few US/
-Canadian cities.   Then, 100 Person records are installed, each with a
-randomly selected postal code.
+"""Installs some sample data.   Here we have a handful of postal codes for
+a few US/Canadian cities.   Then, 100 Person records are installed, each
+with a randomly selected postal code.
 
 """
-from .environment import Session, Base
-from .model import City, Country, PostalCode, Person, Address
 import random
 
+from .environment import Base
+from .environment import Session
+from .model import Address
+from .model import City
+from .model import Country
+from .model import Person
+from .model import PostalCode
+
 
 def install():
     Base.metadata.create_all(Session().bind)
index eb565344e99df29b13058aba572fbbae9b62ce0d..6b03afbdbb01fe3dcab7f71157f8127116b569fa 100644 (file)
@@ -2,9 +2,10 @@
 
 """
 
+from .caching_query import FromCache
 from .environment import Session
 from .model import Person
-from .caching_query import FromCache
+
 
 # load Person objects.  cache the result in the "default" cache region
 print("loading people....")
index 358886bf0aee192fd1a07cb61af4b41feac13a79..1700c7a636d0fe587063c3c52e0e180832a51e95 100644 (file)
@@ -10,7 +10,8 @@ with the basic operation of CachingQuery.
 
 """
 
-from dogpile.cache.api import CacheBackend, NO_VALUE
+from dogpile.cache.api import CacheBackend
+from dogpile.cache.api import NO_VALUE
 from dogpile.cache.region import register_backend
 
 
index f6a25982062f5b845e893aadad49800486f03b02..cae2ae277622df25fffc62a63defcb1d9a41a981 100644 (file)
@@ -7,10 +7,14 @@ PostalCode --(has a)--> City
 City --(has a)--> Country
 
 """
-from sqlalchemy import Column, Integer, String, ForeignKey
+from sqlalchemy import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.orm import relationship
 from .caching_query import RelationshipCache
-from .environment import Base, bootstrap
+from .environment import Base
+from .environment import bootstrap
 
 
 class Country(Base):
index 76c7e767f78c21772c8308cbea85bfc0c31d4d86..6b261ade99d37ed798bc5603c4476e67ffcca9a1 100644 (file)
@@ -6,11 +6,15 @@ related PostalCode, City, Country objects should be pulled from long
 term cache.
 
 """
-from .environment import Session, root
-from .model import Person, cache_address_bits
-from sqlalchemy.orm import joinedload
 import os
 
+from sqlalchemy.orm import joinedload
+from .environment import root
+from .environment import Session
+from .model import cache_address_bits
+from .model import Person
+
+
 for p in Session.query(Person).options(
     joinedload(Person.addresses), cache_address_bits
 ):
index 62da55c3879dedeaf621833c6bfd3a2ca50aeed3..63a23bffb17579fe0e46edd653c5d88d052271b1 100644 (file)
@@ -1,3 +1,13 @@
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import sessionmaker
+
+
 class ProxyDict(object):
     def __init__(self, parent, collection_name, childclass, keyname):
         self.parent = parent
@@ -29,10 +39,6 @@ class ProxyDict(object):
         self.collection.append(value)
 
 
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import create_engine, Column, Integer, String, ForeignKey
-from sqlalchemy.orm import sessionmaker, relationship
-
 engine = create_engine("sqlite://", echo=True)
 Base = declarative_base(engine)
 
index 1f7161212859736e0cec9323961d080390791a7f..6dd88c7973d603b625bd6c3bb15b734701151805 100644 (file)
@@ -1,4 +1,6 @@
-"""Illustrates an explicit way to persist an XML document expressed using ElementTree.
+"""
+Illustrates an explicit way to persist an XML document expressed using
+ElementTree.
 
 Each DOM node is stored in an individual
 table row, with attributes   represented in a separate table.  The
@@ -8,34 +10,37 @@ along any path with a given   structure of attributes, basically a
 (very narrow) subset of xpath.
 
 This example explicitly marshals/unmarshals the ElementTree document into
-mapped entities which have their own tables.  Compare to pickle.py which
-uses pickle to accomplish the same task.  Note that the usage of both
-styles of persistence are identical, as is the structure of the main Document class.
+mapped entities which have their own tables.  Compare to pickle.py which uses
+pickle to accomplish the same task.  Note that the usage of both styles of
+persistence are identical, as is the structure of the main Document class.
 
 """
 
-################################# PART I - Imports/Coniguration ####################################
-from sqlalchemy import (
-    MetaData,
-    Table,
-    Column,
-    Integer,
-    String,
-    ForeignKey,
-    Unicode,
-    and_,
-    create_engine,
-)
-from sqlalchemy.orm import mapper, relationship, Session, lazyload
+# PART I - Imports/Configuration
+import io
+import os
+import re
+from xml.etree import ElementTree
 
-import sys, os, io, re
+from sqlalchemy import and_
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import Unicode
+from sqlalchemy.orm import lazyload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 
-from xml.etree import ElementTree
 
 e = create_engine("sqlite://")
 meta = MetaData()
 
-################################# PART II - Table Metadata #########################################
+# PART II - Table Metadata
 
 # stores a top level record of an XML document.
 documents = Table(
@@ -75,10 +80,12 @@ attributes = Table(
 
 meta.create_all(e)
 
-#################################### PART III - Model #############################################
+# PART III - Model
 
 # our document class.  contains a string name,
 # and the ElementTree root element.
+
+
 class Document(object):
     def __init__(self, name, element):
         self.filename = name
@@ -90,19 +97,22 @@ class Document(object):
         return buf.getvalue()
 
 
-#################################### PART IV - Persistence Mapping #################################
+# PART IV - Persistence Mapping
+
+# Node class.  a non-public class which will represent the DB-persisted
+# Element/SubElement object.  We cannot create mappers for ElementTree elements
+# directly because they are at the very least not new-style classes, and also
+# may be backed by native implementations. so here we construct an adapter.
+
 
-# Node class.  a non-public class which will represent
-# the DB-persisted Element/SubElement object.  We cannot create mappers for
-# ElementTree elements directly because they are at the very least not new-style
-# classes, and also may be backed by native implementations.
-# so here we construct an adapter.
 class _Node(object):
     pass
 
 
-# Attribute class.  also internal, this will represent the key/value attributes stored for
-# a particular Node.
+# Attribute class.  also internal, this will represent the key/value attributes
+# stored for a particular Node.
+
+
 class _Attribute(object):
     def __init__(self, name, value):
         self.name = name
@@ -130,9 +140,12 @@ mapper(
 
 mapper(_Attribute, attributes)
 
-# define marshalling functions that convert from _Node/_Attribute to/from ElementTree objects.
-# this will set the ElementTree element as "document._element", and append the root _Node
-# object to the "_root" mapped collection.
+# define marshalling functions that convert from _Node/_Attribute to/from
+# ElementTree objects. this will set the ElementTree element as
+# "document._element", and append the root _Node object to the "_root" mapped
+# collection.
+
+
 class ElementTreeMarshal(object):
     def __get__(self, document, owner):
         if document is None:
@@ -180,7 +193,7 @@ class ElementTreeMarshal(object):
 # override Document's "element" attribute with the marshaller.
 Document.element = ElementTreeMarshal()
 
-########################################### PART V - Basic Persistence Example #####################
+# PART V - Basic Persistence Example
 
 line = "\n--------------------------------------------------------"
 
@@ -202,7 +215,7 @@ document = session.query(Document).filter_by(filename="test.xml").first()
 
 print(document)
 
-############################################ PART VI - Searching for Paths #########################
+# PART VI - Searching for Paths
 
 # manually search for a document which contains "/somefile/header/field1:hi"
 d = (
@@ -218,6 +231,8 @@ d = (
 print(d)
 
 # generalize the above approach into an extremely impoverished xpath function:
+
+
 def find_document(path, compareto):
     j = documents
     prev_elements = None
index 8e9c48b96b0046a35cbc0f656809508a2f78b4ad..b66ada19d04e249a2d8464d378a47bc6c39a529a 100644 (file)
@@ -7,28 +7,32 @@
 
 """
 
-##################### PART I - Imports/Configuration #########################
-from sqlalchemy import (
-    MetaData,
-    Table,
-    Column,
-    Integer,
-    String,
-    ForeignKey,
-    Unicode,
-    and_,
-    create_engine,
-)
-from sqlalchemy.orm import mapper, relationship, Session, lazyload
-
-import sys, os, io, re
+# PART I - Imports/Configuration
 
+import io
+import os
+import re
 from xml.etree import ElementTree
 
+from sqlalchemy import and_
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import Unicode
+from sqlalchemy.orm import lazyload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+
+
 e = create_engine("sqlite://", echo=True)
 meta = MetaData()
 
-####################### PART II - Table Metadata #############################
+# PART II - Table Metadata
 
 # stores a top level record of an XML document.
 documents = Table(
@@ -68,10 +72,12 @@ attributes = Table(
 
 meta.create_all(e)
 
-########################### PART III - Model #################################
+# PART III - Model
 
 # our document class.  contains a string name,
 # and the ElementTree root element.
+
+
 class Document(object):
     def __init__(self, name, element):
         self.filename = name
@@ -83,19 +89,22 @@ class Document(object):
         return buf.getvalue()
 
 
-########################## PART IV - Persistence Mapping #####################
+# PART IV - Persistence Mapping
+
+# Node class.  a non-public class which will represent the DB-persisted
+# Element/SubElement object.  We cannot create mappers for ElementTree elements
+# directly because they are at the very least not new-style classes, and also
+# may be backed by native implementations. so here we construct an adapter.
+
 
-# Node class.  a non-public class which will represent
-# the DB-persisted Element/SubElement object.  We cannot create mappers for
-# ElementTree elements directly because they are at the very least not new-style
-# classes, and also may be backed by native implementations.
-# so here we construct an adapter.
 class _Node(object):
     pass
 
 
-# Attribute class.  also internal, this will represent the key/value attributes stored for
-# a particular Node.
+# Attribute class.  also internal, this will represent the key/value attributes
+# stored for a particular Node.
+
+
 class _Attribute(object):
     def __init__(self, name, value):
         self.name = name
@@ -115,10 +124,11 @@ mapper(
     },
 )
 
-# the _Node objects change the way they load so that a list of _Nodes will organize
-# themselves hierarchically using the ElementTreeMarshal.  this depends on the ordering of
-# nodes being hierarchical as well; relationship() always applies at least ROWID/primary key
-# ordering to rows which will suffice.
+# the _Node objects change the way they load so that a list of _Nodes will
+# organize themselves hierarchically using the ElementTreeMarshal.  this
+# depends on the ordering of nodes being hierarchical as well; relationship()
+# always applies at least ROWID/primary key ordering to rows which will
+# suffice.
 mapper(
     _Node,
     elements,
@@ -134,9 +144,12 @@ mapper(
 
 mapper(_Attribute, attributes)
 
-# define marshalling functions that convert from _Node/_Attribute to/from ElementTree objects.
-# this will set the ElementTree element as "document._element", and append the root _Node
-# object to the "_nodes" mapped collection.
+# define marshalling functions that convert from _Node/_Attribute to/from
+# ElementTree objects. this will set the ElementTree element as
+# "document._element", and append the root _Node object to the "_nodes" mapped
+# collection.
+
+
 class ElementTreeMarshal(object):
     def __get__(self, document, owner):
         if document is None:
@@ -188,7 +201,7 @@ class ElementTreeMarshal(object):
 # override Document's "element" attribute with the marshaller.
 Document.element = ElementTreeMarshal()
 
-###################### PART V - Basic Persistence Example ####################
+# PART V - Basic Persistence Example
 
 line = "\n--------------------------------------------------------"
 
@@ -210,7 +223,7 @@ document = session.query(Document).filter_by(filename="test.xml").first()
 
 print(document)
 
-######################## PART VI - Searching for Paths #######################
+# PART VI - Searching for Paths
 
 # manually search for a document which contains "/somefile/header/field1:hi"
 print("\nManual search for /somefile/header/field1=='hi':", line)
@@ -227,6 +240,8 @@ d = (
 print(d)
 
 # generalize the above approach into an extremely impoverished xpath function:
+
+
 def find_document(path, compareto):
     j = documents
     prev_elements = None
index a86fe30e560a11c2c568dc1801bac6358927bf61..ca2c6550494ea305a82fa5701e9f3f0a83d287d5 100644 (file)
@@ -1,31 +1,37 @@
-"""illustrates a quick and dirty way to persist an XML document expressed using ElementTree and pickle.
+"""
+illustrates a quick and dirty way to persist an XML document expressed using
+ElementTree and pickle.
 
 This is a trivial example using PickleType to marshal/unmarshal the ElementTree
-document into a binary column.  Compare to explicit.py which stores the individual components of the ElementTree
-structure in distinct rows using two additional mapped entities.  Note that the usage of both
-styles of persistence are identical, as is the structure of the main Document class.
+document into a binary column.  Compare to explicit.py which stores the
+individual components of the ElementTree structure in distinct rows using two
+additional mapped entities.  Note that the usage of both styles of persistence
+are identical, as is the structure of the main Document class.
+
 """
 
-from sqlalchemy import (
-    create_engine,
-    MetaData,
-    Table,
-    Column,
-    Integer,
-    String,
-    PickleType,
-)
-from sqlalchemy.orm import mapper, Session
+import os
+import sys
+from xml.etree import ElementTree
 
-import sys, os
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import PickleType
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Session
 
-from xml.etree import ElementTree
 
 e = create_engine("sqlite://")
 meta = MetaData()
 
 # setup a comparator for the PickleType since it's a mutable
 # element.
+
+
 def are_elements_equal(x, y):
     return x == y
 
@@ -44,6 +50,8 @@ meta.create_all(e)
 
 # our document class.  contains a string name,
 # and the ElementTree root element.
+
+
 class Document(object):
     def __init__(self, name, element):
         self.filename = name
@@ -53,7 +61,7 @@ class Document(object):
 # setup mapper.
 mapper(Document, documents)
 
-###### time to test ! #########
+# time to test !
 
 # get ElementTree document
 filename = os.path.join(os.path.dirname(__file__), "test.xml")
index 9d103b73e70de9a8eeb72ccce6ffc66a13f2c855..dd6f5321b735d64e609c8ade99b4bc60e679edf2 100644 (file)
@@ -15,4 +15,4 @@ are modernized versions of recipes presented in the 2007 blog post
 
 .. autosource::
 
-"""
+"""  # noqa
index 38f2370f3d605bff9c685215806625fd0125a70e..95020884646e80298450012103fae869af788cb6 100644 (file)
@@ -15,10 +15,17 @@ it uses a fixed number of tables to serve any number of potential parent
 objects, but is also slightly more complex.
 
 """
-from sqlalchemy.ext.declarative import as_declarative, declared_attr
-from sqlalchemy import create_engine, Integer, Column, String, ForeignKey
-from sqlalchemy.orm import Session, relationship, backref
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.ext.associationproxy import association_proxy
+from sqlalchemy.ext.declarative import as_declarative
+from sqlalchemy.ext.declarative import declared_attr
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 
 
 @as_declarative()
index ded8f749d13869ba3e39874eddd5f35221ca6bd5..23145ed4c673af53e7f6fcc1767c43d844fbe736 100644 (file)
@@ -19,10 +19,19 @@ or "table_per_association" instead of this approach.
 .. versionadded:: 0.8.3
 
 """
-from sqlalchemy.ext.declarative import as_declarative, declared_attr
-from sqlalchemy import create_engine, Integer, Column, String, and_
-from sqlalchemy.orm import Session, relationship, foreign, remote, backref
+from sqlalchemy import and_
+from sqlalchemy import Column
+from sqlalchemy import create_engine
 from sqlalchemy import event
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import as_declarative
+from sqlalchemy.ext.declarative import declared_attr
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import foreign
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import remote
+from sqlalchemy.orm import Session
 
 
 @as_declarative()
index 7de2469345d7fa1ba77312d6df5991cec5a06dec..98c76ef7bed96d06680da9571ecab815ddab515f 100644 (file)
@@ -11,16 +11,16 @@ has no dependency on the system.
 
 
 """
-from sqlalchemy.ext.declarative import as_declarative, declared_attr
-from sqlalchemy import (
-    create_engine,
-    Integer,
-    Column,
-    String,
-    ForeignKey,
-    Table,
-)
-from sqlalchemy.orm import Session, relationship
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy.ext.declarative import as_declarative
+from sqlalchemy.ext.declarative import declared_attr
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 
 
 @as_declarative()
index 9c5e0e1798e040264f88672ed102ed4646ec28e2..3f09e538b0e4dc464c6993ce0600468226f1a429 100644 (file)
@@ -16,9 +16,15 @@ but there really isn't any - the management and targeting of these tables
 is completely automated.
 
 """
-from sqlalchemy.ext.declarative import as_declarative, declared_attr
-from sqlalchemy import create_engine, Integer, Column, String, ForeignKey
-from sqlalchemy.orm import Session, relationship
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import as_declarative
+from sqlalchemy.ext.declarative import declared_attr
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 
 
 @as_declarative()
index af85a4295f6e51b3c0d1564f5c640988ce193bb1..d6611eaa79d0031d9fb9e9e33dc362595cbf71ca 100644 (file)
@@ -1,8 +1,13 @@
 """a directed graph example."""
 
-from sqlalchemy import Column, Integer, ForeignKey, create_engine
-from sqlalchemy.orm import relationship, sessionmaker
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import sessionmaker
+
 
 Base = declarative_base()
 
index 2245aa4e0e802714d96c5d07dff2b77d69919f3f..4eb89984a0b6336d3c654cc7c165e71752566a67 100644 (file)
@@ -1,17 +1,17 @@
 """Concrete-table (table-per-class) inheritance example."""
 
-from sqlalchemy import (
-    Column,
-    Integer,
-    String,
-    ForeignKey,
-    create_engine,
-    inspect,
-    or_,
-)
-from sqlalchemy.orm import relationship, Session, with_polymorphic
-from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import or_
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import ConcreteBase
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import with_polymorphic
 
 
 Base = declarative_base()
index a3a61d76302d0b3d27281d57d0065c9a4405a462..74a6e364922026efb7b91b594f1c2e3a9678fb34 100644 (file)
@@ -1,16 +1,17 @@
 """Joined-table (table-per-subclass) inheritance example."""
 
-from sqlalchemy import (
-    Column,
-    Integer,
-    String,
-    ForeignKey,
-    create_engine,
-    inspect,
-    or_,
-)
-from sqlalchemy.orm import relationship, Session, with_polymorphic
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import or_
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import with_polymorphic
+
 
 Base = declarative_base()
 
index 46d690c9437ed77b9c84417e7ba9514b594a3bc2..0d5871cb11cb4376995b1d037917892ab9e1d927 100644 (file)
@@ -1,16 +1,18 @@
 """Single-table (table-per-hierarchy) inheritance example."""
 
-from sqlalchemy import (
-    Column,
-    Integer,
-    String,
-    ForeignKey,
-    create_engine,
-    inspect,
-    or_,
-)
-from sqlalchemy.orm import relationship, Session, with_polymorphic
-from sqlalchemy.ext.declarative import declarative_base, declared_attr
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import or_
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.ext.declarative import declared_attr
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import with_polymorphic
+
 
 Base = declarative_base()
 
index 7ea77568998921bc01c7bb2b54cf30554f37c904..e175bc227ca1a1a23c81a58cda2553bc8286b9d6 100644 (file)
@@ -29,9 +29,16 @@ in order to note to the ORM that ``B.a_id`` should be treated like the
 "foreign key" column.
 
 """
-from sqlalchemy import *
-from sqlalchemy.orm import *
+
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import TypeDecorator
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+
 
 Base = declarative_base()
 
index 25700263745d18c666ea49560f26abb8575c8a35..aca3b0c2f30ae7fc992c70abfe686692662d7535 100644 (file)
@@ -33,9 +33,18 @@ a Query (or a :func:`.relationship`).
 
 
 """
-from sqlalchemy import *
-from sqlalchemy.orm import *
+from sqlalchemy import and_
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import join
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import foreign
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+
 
 Base = declarative_base()
 
index eb014c6cb0be0def037db67888b62ce73a9449ee..0f34c54dc75bedcd5c304059a55f471d44c77249 100644 (file)
@@ -1,13 +1,13 @@
-from sqlalchemy import (
-    MetaData,
-    Table,
-    Column,
-    Integer,
-    String,
-    ForeignKey,
-    create_engine,
-)
-from sqlalchemy.orm import mapper, relationship, sessionmaker
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import sessionmaker
 
 
 meta = MetaData()
@@ -56,8 +56,8 @@ mapper(
             # Member objects "belong" to their parent, are deleted when
             # removed from the collection
             cascade="all, delete-orphan",
-            # "delete, delete-orphan" cascade does not load in objects on delete,
-            # allows ON DELETE CASCADE to handle it.
+            # "delete, delete-orphan" cascade does not load in objects on
+            # delete, allows ON DELETE CASCADE to handle it.
             # this only works with a database that supports ON DELETE CASCADE -
             # *not* sqlite or MySQL with MyISAM
             passive_deletes=True,
@@ -108,7 +108,8 @@ if __name__ == "__main__":
     # disappear automatically without the need for additional SQL.
     sess.delete(org)
     print(
-        "-------------------------\nflush three - delete org, delete members in one statement\n"
+        "-------------------------\nflush three - delete org, "
+        "delete members in one statement\n"
     )
     sess.commit()
 
index 45ae0c1932fcfe8ed33c5bf270b092acfd687af3..f777f131bed4347ad7433a7e5b9b58b4dadca15b 100644 (file)
@@ -26,11 +26,20 @@ already stored in the path itself. Updates require going through all
 descendants and changing the prefix.
 
 """
-from sqlalchemy import Column, Integer, String, func, select, create_engine
-from sqlalchemy.orm import remote, foreign, relationship, Session
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy.dialects.postgresql import ARRAY
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import foreign
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import remote
+from sqlalchemy.orm import Session
 from sqlalchemy.sql.expression import cast
-from sqlalchemy.dialects.postgresql import ARRAY
+
 
 Base = declarative_base()
 
index 705a3d279ec7f34bd15e561726501e2194d748e6..ba45231ceeb8ba255ec3eda0bbde77801dd31ced 100644 (file)
@@ -4,18 +4,18 @@ http://www.intelligententerprise.com/001020/celko.jhtml
 
 """
 
-from sqlalchemy import (
-    create_engine,
-    Column,
-    Integer,
-    String,
-    select,
-    case,
-    func,
-)
-from sqlalchemy.orm import Session, aliased
-from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy import case
+from sqlalchemy import Column
+from sqlalchemy import create_engine
 from sqlalchemy import event
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import Session
+
 
 Base = declarative_base()
 
index b66199f3c343fede274b9bdb31d2c6dae76969ec..f1f59026c2d94256651905c473ad58ede14c4b4e 100644 (file)
@@ -31,8 +31,8 @@ individual suites to be run::
       -h, --help            show this help message and exit
       --test TEST           run specific test name
       --dburl DBURL         database URL, default sqlite:///profile.db
-      --num NUM             Number of iterations/items/etc for tests; default is 0
-                            module-specific
+      --num NUM             Number of iterations/items/etc for tests;
+                            default is module-specific
       --profile             run profiling and dump call counts
       --dump                dump full call profile (implies --profile)
       --runsnake            invoke runsnakerun (implies --profile)
@@ -217,14 +217,14 @@ As well as see RunSnake output for an individual test::
 
     $ python test_loads.py  --num 100 --runsnake --test test_joinedload
 
-"""
+"""  # noqa
 import argparse
 import cProfile
-import pstats
 import os
-import time
+import pstats
 import re
 import sys
+import time
 
 
 class Profiler(object):
index 945458651a73e9e1aef498a375c446637d29c381..aeb124e1d1f553e3f90fa1bf32337b6d320eef9f 100644 (file)
@@ -2,5 +2,6 @@
 
 from . import Profiler
 
+
 if __name__ == "__main__":
     Profiler.main()
index 52f0f32e67774c606f7da5f490f88a645ed668bd..49469581d4ed8d4b833013c5106c5969b931ad4b 100644 (file)
@@ -3,11 +3,15 @@ of rows in bulk.
 
 
 """
-from . import Profiler
-
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, Integer, String, create_engine, bindparam
 from sqlalchemy.orm import Session
+from . import Profiler
+
 
 Base = declarative_base()
 engine = None
index ebb700068694bc5b59f7f4d760d9313c51f65175..0657c96f326ef8a444f7d5c089b59e846327109b 100644 (file)
@@ -3,11 +3,14 @@ of rows in bulk.
 
 
 """
-from . import Profiler
-
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, Integer, String, create_engine, bindparam
 from sqlalchemy.orm import Session
+from . import Profiler
+
 
 Base = declarative_base()
 engine = None
index ad1c2319410eb44d8080176c92d43e0696a14d87..2945040b5a8f4de7532456f4b663244d71c5643e 100644 (file)
@@ -13,11 +13,15 @@ full blown ORM doesn't do terribly either even though mapped objects
 provide a huge amount of functionality.
 
 """
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import Bundle
+from sqlalchemy.orm import Session
 from . import Profiler
 
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, Integer, String, create_engine
-from sqlalchemy.orm import Session, Bundle
 
 Base = declarative_base()
 engine = None
@@ -165,8 +169,8 @@ def _test_dbapi_raw(n, make_objects):
         # going to do this, so see how this pushes you right back into
         # ORM land anyway :)
         class SimpleCustomer(object):
-            def __init__(self, id, name, description):
-                self.id = id
+            def __init__(self, id_, name, description):
+                self.id = id_
                 self.name = name
                 self.description = description
 
index 4a8d401ad0b388a21d2c83bc2efb48fd97b959a5..376f18f02d652b3a8a02dc7ebc45ed3f0c9e31e5 100644 (file)
@@ -3,20 +3,20 @@ record by primary key
 
 
 """
-from . import Profiler
+import random
 
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import (
-    Column,
-    Integer,
-    String,
-    create_engine,
-    bindparam,
-    select,
-)
-from sqlalchemy.orm import Session, deferred
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy.ext import baked
-import random
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import Session
+from . import Profiler
+
 
 Base = declarative_base()
 engine = None
index 79e34dfe6b1138963d41b061e6111651efba1017..428eb5c4126d38b6fbe1307f0c97a5eedfecef28 100644 (file)
@@ -4,11 +4,16 @@ within a distinct transaction, and afterwards returns to essentially a
 a database connection, inserts the row, commits and closes.
 
 """
-from . import Profiler
-
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import pool
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, Integer, String, create_engine, bindparam, pool
 from sqlalchemy.orm import Session
+from . import Profiler
+
 
 Base = declarative_base()
 engine = None
index 66ae65d3c06adc3dbd9bfcc775d5b0ebd2bae014..963a561f3d2ea7116d1891710bf115635a8bcc27 100644 (file)
@@ -31,7 +31,8 @@ and simple to use extension points.
 
 E.g.::
 
-    print session.query(Road).filter(Road.road_geom.intersects(r1.road_geom)).all()
+    print session.query(Road).filter(
+        Road.road_geom.intersects(r1.road_geom)).all()
 
 .. autosource::
 
index 508d6339882f06731f8021fc9a342e7672883bd1..868d3d055da030ae30173c7a6253b5a29219c850 100644 (file)
@@ -1,8 +1,12 @@
-from sqlalchemy.types import UserDefinedType, _Binary, TypeDecorator
-from sqlalchemy.sql import expression, type_coerce
-from sqlalchemy import event, Table
 import binascii
 
+from sqlalchemy import event
+from sqlalchemy import Table
+from sqlalchemy.sql import expression
+from sqlalchemy.sql import type_coerce
+from sqlalchemy.types import UserDefinedType
+
+
 # Python datatypes
 
 
@@ -278,7 +282,8 @@ if __name__ == "__main__":
         ]
     )
 
-    # or use an explicit TextualGisElement (similar to saying func.GeomFromText())
+    # or use an explicit TextualGisElement
+    # (similar to saying func.GeomFromText())
     r = Road(
         road_name="Dave Cres",
         road_geom=TextualGisElement(
@@ -292,7 +297,8 @@ if __name__ == "__main__":
 
     session.commit()
 
-    # after flush and/or commit, all the TextualGisElements become PersistentGisElements.
+    # after flush and/or commit, all the TextualGisElements
+    # become PersistentGisElements.
     assert str(r.road_geom) == "LINESTRING(198231 263418,198213 268322)"
 
     r1 = session.query(Road).filter(Road.road_name == "Graeme Ave").one()
@@ -318,16 +324,16 @@ if __name__ == "__main__":
     )
     print(session.execute(stmt).fetchall())
 
-    # TODO: for some reason the auto-generated labels have the internal replacement
-    # strings exposed, even though PG doesn't complain
+    # TODO: for some reason the auto-generated labels have the internal
+    # replacement strings exposed, even though PG doesn't complain
 
     # look up the hex binary version, using SQLAlchemy casts
     as_binary = session.scalar(
         select([type_coerce(r.road_geom, Geometry(coerce_="binary"))])
     )
-    assert (
-        as_binary.as_hex
-        == "01020000000200000000000000b832084100000000e813104100000000283208410000000088601041"
+    assert as_binary.as_hex == (
+        "01020000000200000000000000b832084100000000"
+        "e813104100000000283208410000000088601041"
     )
 
     # back again, same method !
index 59d26a2175b3acda97ea30ac9bdec61ee812440e..eb8e10686fb188938630fa3c1e7917e316780af0 100644 (file)
@@ -8,7 +8,7 @@ The basic components of a "sharded" mapping are:
 * a function which can return a single shard id, given an instance
   to be saved; this is called "shard_chooser"
 * a function which can return a list of shard ids which apply to a particular
-  instance identifier; this is called "id_chooser".  If it returns all shard ids,
+  instance identifier; this is called "id_chooser".If it returns all shard ids,
   all shards will be searched.
 * a function which can return a list of shard ids to try, given a particular
   Query ("query_chooser").  If it returns all shard ids, all shards will be
index 48a3dc9325d94e0fedc17523d3ccb7cf6b692f1d..608f0f9c3a437e6968c080c3a2bc4976491ca91d 100644 (file)
@@ -1,20 +1,21 @@
-from sqlalchemy import (
-    create_engine,
-    Table,
-    Column,
-    Integer,
-    String,
-    ForeignKey,
-    Float,
-    DateTime,
-)
-from sqlalchemy.orm import sessionmaker, relationship
-from sqlalchemy.ext.horizontal_shard import ShardedSession
-from sqlalchemy.sql import operators, visitors
-from sqlalchemy.ext.declarative import declarative_base
+import datetime
+
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import DateTime
+from sqlalchemy import Float
+from sqlalchemy import ForeignKey
 from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.ext.horizontal_shard import ShardedSession
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.sql import operators
+from sqlalchemy.sql import visitors
 
-import datetime
 
 # db1 is used for id generation. The "pool_threadlocal"
 # causes the id_generator() to use the same connection as that
index d5437d8cf0fdfff25139ee11de21c939e370c060..34d233da183c1e9fa715a2bb0f072857db76d3c5 100644 (file)
@@ -1,14 +1,24 @@
-import sys
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import create_engine, Integer, Column, ForeignKey, String, func
-from sqlalchemy.orm import relationship, Session, joinedload
-from sqlalchemy.ext.hybrid import hybrid_property, hybrid_method
 import curses
-import time
-import textwrap
-import re
-import random
 import logging
+import random
+import re
+import sys
+import textwrap
+import time
+
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.ext.hybrid import hybrid_method
+from sqlalchemy.ext.hybrid import hybrid_property
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+
 
 _PY3 = sys.version_info > (3, 0)
 if _PY3:
@@ -39,7 +49,6 @@ PAUSE_KEY = ord("p")
 
 COLOR_MAP = {
     "K": curses.COLOR_BLACK,
-    "R": curses.COLOR_RED,
     "B": curses.COLOR_BLUE,
     "C": curses.COLOR_CYAN,
     "G": curses.COLOR_GREEN,
index 7670cd613249b2106f39cb36df878afd50f7ff5e..e6db1fc2ca01e0eee157297f83500b1942e7dae3 100644 (file)
@@ -1,7 +1,7 @@
 """
 Illustrates an extension which creates version tables for entities and stores
-records for each change. The given extensions generate an anonymous "history" class which
-represents historical versions of the target object.
+records for each change. The given extensions generate an anonymous "history"
+class which represents historical versions of the target object.
 
 Compare to the :ref:`examples_versioned_rows` examples which write updates
 as new rows in the same table, without using a separate history table.
index 749a6a5cabd15ee236708ecf117e529eb1060d63..2a331443d7cc105141b6f883eba260b0ab6d23de 100644 (file)
@@ -1,11 +1,19 @@
 """Versioned mixin class and other utilities."""
 
+import datetime
+
+from sqlalchemy import Column
+from sqlalchemy import DateTime
+from sqlalchemy import event
+from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import Integer
+from sqlalchemy import Table
+from sqlalchemy import util
 from sqlalchemy.ext.declarative import declared_attr
-from sqlalchemy.orm import mapper, attributes, object_mapper
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import object_mapper
 from sqlalchemy.orm.exc import UnmappedColumnError
-from sqlalchemy import Table, Column, ForeignKeyConstraint, Integer, DateTime
-from sqlalchemy import event, util
-import datetime
 from sqlalchemy.orm.properties import RelationshipProperty
 
 
@@ -165,20 +173,20 @@ def _history_mapper(local_mapper):
 class Versioned(object):
     @declared_attr
     def __mapper_cls__(cls):
-        def map(cls, *arg, **kw):
+        def map_(cls, *arg, **kw):
             mp = mapper(cls, *arg, **kw)
             _history_mapper(mp)
             return mp
 
-        return map
+        return map_
 
     __table_args__ = {"sqlite_autoincrement": True}
     """Use sqlite_autoincrement, to ensure unique integer values
     are used for new rows even for rows taht have been deleted."""
 
 
-def versioned_objects(iter):
-    for obj in iter:
+def versioned_objects(iter_):
+    for obj in iter_:
         if hasattr(obj, "__history_mapper__"):
             yield obj
 
index 3270ad5fdaf58aaec0600daa5c4f2b92d5a1553a..44e545749441a4f28dc20407509874e7ff6a2274 100644 (file)
@@ -2,28 +2,30 @@
 module functions."""
 
 from unittest import TestCase
+import warnings
+
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
-from .history_meta import Versioned, versioned_session
-from sqlalchemy import (
-    create_engine,
-    Column,
-    Integer,
-    String,
-    ForeignKey,
-    Boolean,
-    select,
-)
-from sqlalchemy.orm import (
-    clear_mappers,
-    Session,
-    deferred,
-    relationship,
-    column_property,
-)
-from sqlalchemy.testing import AssertsCompiledSQL, eq_, assert_raises, ne_
-from sqlalchemy.testing.entities import ComparableEntity
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import deferred
 from sqlalchemy.orm import exc as orm_exc
-import warnings
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing.entities import ComparableEntity
+from .history_meta import Versioned
+from .history_meta import versioned_session
+
 
 warnings.simplefilter("error")
 
index 46bdbb78395607cb06627d1497e6600853f693bf..9abbb3e09cdddba94e4179a16ce1a5827ee30f66 100644 (file)
@@ -28,20 +28,22 @@ those additional values.
 
 """
 
-from sqlalchemy import Column, String, Integer, ForeignKey, create_engine
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.orm import (
-    attributes,
-    relationship,
-    backref,
-    sessionmaker,
-    make_transient,
-    validates,
-    Session,
-)
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.ext.associationproxy import association_proxy
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import make_transient
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import validates
 from sqlalchemy.orm.collections import attribute_mapped_collection
-from sqlalchemy import event
 
 
 @event.listens_for(Session, "before_flush")
index 03e1c351012dabc6dc9d61f58ad7d8b2825a5a6d..01067431c88a00d9ce619adaae5d18ba130f8019 100644 (file)
@@ -3,17 +3,19 @@ an UPDATE statement on a single row into an INSERT statement, so that a new
 row is inserted with the new data, keeping the old row intact.
 
 """
-from sqlalchemy.orm import (
-    sessionmaker,
-    relationship,
-    make_transient,
-    backref,
-    Session,
-)
-from sqlalchemy import Column, ForeignKey, create_engine, Integer, String
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
 from sqlalchemy.orm import attributes
-from sqlalchemy import event
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import make_transient
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
 
 
 class Versioned(object):
index 5fd6f9fc4193610b69cb0b038c5b3a56c0648897..4861fb3669c4eab080e139bdda5efe88e25a1f64 100644 (file)
@@ -6,27 +6,23 @@ This example adds a numerical version_id to the Versioned class as well
 as the ability to see which row is the most "current" vesion.
 
 """
-from sqlalchemy.orm import (
-    sessionmaker,
-    relationship,
-    make_transient,
-    backref,
-    Session,
-    column_property,
-)
-from sqlalchemy import (
-    Column,
-    ForeignKeyConstraint,
-    create_engine,
-    Integer,
-    String,
-    Boolean,
-    select,
-    func,
-)
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import event
+from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy.ext.declarative import declarative_base
 from sqlalchemy.orm import attributes
-from sqlalchemy import event
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import make_transient
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
 
 
 class Versioned(object):
index 17c82fdc37bb4a3dee9d5212d5a4b0ad2d58b2cf..5aa0f424af3bf41d0ac5d348cca1ddf9d3c877de 100644 (file)
@@ -5,29 +5,27 @@ to only the most recent version.
 
 """
 
-from sqlalchemy import (
-    create_engine,
-    Integer,
-    String,
-    event,
-    Column,
-    DateTime,
-    inspect,
-    literal,
-)
-from sqlalchemy.orm import (
-    make_transient,
-    Session,
-    relationship,
-    attributes,
-    backref,
-    make_transient_to_detached,
-    Query,
-)
-from sqlalchemy.ext.declarative import declarative_base
 import datetime
 import time
 
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import DateTime
+from sqlalchemy import event
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import make_transient
+from sqlalchemy.orm import make_transient_to_detached
+from sqlalchemy.orm import Query
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+
+
 Base = declarative_base()
 
 # this will be the current time as the test runs
index c000ff3cf927dca35c07ac7d08f392ff17bb96ed..73d12ee4f2592db307fd29bffbe9ce1f938f3cc6 100644 (file)
@@ -24,10 +24,10 @@ date.
 
 """
 
-from sqlalchemy.orm.interfaces import PropComparator
-from sqlalchemy.ext.hybrid import hybrid_property
 from sqlalchemy import event
 from sqlalchemy import literal_column
+from sqlalchemy.ext.hybrid import hybrid_property
+from sqlalchemy.orm.interfaces import PropComparator
 from .dictlike import ProxiedDictMixin
 
 
index 171f2302892eccc02e5cb17d4f3d42c50ea81a21..3df12f5c95ee0a31e67c1866bbbb83ef79d95ccc 100644 (file)
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
+from . import util as _util  # noqa
+from .inspection import inspect  # noqa
+from .schema import BLANK_SCHEMA  # noqa
+from .schema import CheckConstraint  # noqa
+from .schema import Column  # noqa
+from .schema import ColumnDefault  # noqa
+from .schema import Constraint  # noqa
+from .schema import DDL  # noqa
+from .schema import DefaultClause  # noqa
+from .schema import FetchedValue  # noqa
+from .schema import ForeignKey  # noqa
+from .schema import ForeignKeyConstraint  # noqa
+from .schema import Index  # noqa
+from .schema import MetaData  # noqa
+from .schema import PassiveDefault  # noqa
+from .schema import PrimaryKeyConstraint  # noqa
+from .schema import Sequence  # noqa
+from .schema import Table  # noqa
+from .schema import ThreadLocalMetaData  # noqa
+from .schema import UniqueConstraint  # noqa
+from .sql import alias  # noqa
+from .sql import all_  # noqa
+from .sql import and_  # noqa
+from .sql import any_  # noqa
+from .sql import asc  # noqa
+from .sql import between  # noqa
+from .sql import bindparam  # noqa
+from .sql import case  # noqa
+from .sql import cast  # noqa
+from .sql import collate  # noqa
+from .sql import column  # noqa
+from .sql import delete  # noqa
+from .sql import desc  # noqa
+from .sql import distinct  # noqa
+from .sql import except_  # noqa
+from .sql import except_all  # noqa
+from .sql import exists  # noqa
+from .sql import extract  # noqa
+from .sql import false  # noqa
+from .sql import func  # noqa
+from .sql import funcfilter  # noqa
+from .sql import insert  # noqa
+from .sql import intersect  # noqa
+from .sql import intersect_all  # noqa
+from .sql import join  # noqa
+from .sql import lateral  # noqa
+from .sql import literal  # noqa
+from .sql import literal_column  # noqa
+from .sql import modifier  # noqa
+from .sql import not_  # noqa
+from .sql import null  # noqa
+from .sql import nullsfirst  # noqa
+from .sql import nullslast  # noqa
+from .sql import or_  # noqa
+from .sql import outerjoin  # noqa
+from .sql import outparam  # noqa
+from .sql import over  # noqa
+from .sql import select  # noqa
+from .sql import subquery  # noqa
+from .sql import table  # noqa
+from .sql import tablesample  # noqa
+from .sql import text  # noqa
+from .sql import true  # noqa
+from .sql import tuple_  # noqa
+from .sql import type_coerce  # noqa
+from .sql import union  # noqa
+from .sql import union_all  # noqa
+from .sql import update  # noqa
+from .sql import within_group  # noqa
+from .types import ARRAY  # noqa
+from .types import BIGINT  # noqa
+from .types import BigInteger  # noqa
+from .types import BINARY  # noqa
+from .types import Binary  # noqa
+from .types import BLOB  # noqa
+from .types import BOOLEAN  # noqa
+from .types import Boolean  # noqa
+from .types import CHAR  # noqa
+from .types import CLOB  # noqa
+from .types import DATE  # noqa
+from .types import Date  # noqa
+from .types import DATETIME  # noqa
+from .types import DateTime  # noqa
+from .types import DECIMAL  # noqa
+from .types import Enum  # noqa
+from .types import FLOAT  # noqa
+from .types import Float  # noqa
+from .types import INT  # noqa
+from .types import INTEGER  # noqa
+from .types import Integer  # noqa
+from .types import Interval  # noqa
+from .types import JSON  # noqa
+from .types import LargeBinary  # noqa
+from .types import NCHAR  # noqa
+from .types import NUMERIC  # noqa
+from .types import Numeric  # noqa
+from .types import NVARCHAR  # noqa
+from .types import PickleType  # noqa
+from .types import REAL  # noqa
+from .types import SMALLINT  # noqa
+from .types import SmallInteger  # noqa
+from .types import String  # noqa
+from .types import TEXT  # noqa
+from .types import Text  # noqa
+from .types import TIME  # noqa
+from .types import Time  # noqa
+from .types import TIMESTAMP  # noqa
+from .types import TypeDecorator  # noqa
+from .types import Unicode  # noqa
+from .types import UnicodeText  # noqa
+from .types import VARBINARY  # noqa
+from .types import VARCHAR  # noqa
+
+from .engine import create_engine  # noqa nosort
+from .engine import engine_from_config  # noqa nosort
 
-from .sql import (
-    alias,
-    all_,
-    and_,
-    any_,
-    asc,
-    between,
-    bindparam,
-    case,
-    cast,
-    collate,
-    column,
-    delete,
-    desc,
-    distinct,
-    except_,
-    except_all,
-    exists,
-    extract,
-    false,
-    func,
-    funcfilter,
-    insert,
-    intersect,
-    intersect_all,
-    join,
-    lateral,
-    literal,
-    literal_column,
-    modifier,
-    not_,
-    null,
-    nullsfirst,
-    nullslast,
-    or_,
-    outerjoin,
-    outparam,
-    over,
-    select,
-    subquery,
-    table,
-    tablesample,
-    text,
-    true,
-    tuple_,
-    type_coerce,
-    union,
-    union_all,
-    update,
-    within_group,
-)
-
-from .types import (
-    ARRAY,
-    BIGINT,
-    BINARY,
-    BLOB,
-    BOOLEAN,
-    BigInteger,
-    Binary,
-    Boolean,
-    CHAR,
-    CLOB,
-    DATE,
-    DATETIME,
-    DECIMAL,
-    Date,
-    DateTime,
-    Enum,
-    FLOAT,
-    Float,
-    INT,
-    INTEGER,
-    Integer,
-    Interval,
-    JSON,
-    LargeBinary,
-    NCHAR,
-    NVARCHAR,
-    NUMERIC,
-    Numeric,
-    PickleType,
-    REAL,
-    SMALLINT,
-    SmallInteger,
-    String,
-    TEXT,
-    TIME,
-    TIMESTAMP,
-    Text,
-    Time,
-    TypeDecorator,
-    Unicode,
-    UnicodeText,
-    VARBINARY,
-    VARCHAR,
-)
-
-
-from .schema import (
-    CheckConstraint,
-    Column,
-    ColumnDefault,
-    Constraint,
-    DefaultClause,
-    FetchedValue,
-    ForeignKey,
-    ForeignKeyConstraint,
-    Index,
-    MetaData,
-    PassiveDefault,
-    PrimaryKeyConstraint,
-    Sequence,
-    Table,
-    ThreadLocalMetaData,
-    UniqueConstraint,
-    DDL,
-    BLANK_SCHEMA,
-)
-
-
-from .inspection import inspect
-from .engine import create_engine, engine_from_config
 
 __version__ = "1.3.0b2"
 
@@ -136,7 +128,7 @@ __version__ = "1.3.0b2"
 def __go(lcls):
     global __all__
 
-    from . import events
+    from . import events  # noqa
     from . import util as _sa_util
 
     import inspect as _inspect
index 209877e4a5063eee40a7e67a74a9e6e1db68841e..1cd695269b942ab0427bf35652192d46b07b3a87 100644 (file)
@@ -19,8 +19,8 @@ For more info on mxODBC, see http://www.egenix.com/
 
 """
 
-import sys
 import re
+import sys
 import warnings
 
 from . import Connector
@@ -89,7 +89,7 @@ class MxODBCConnector(Connector):
         return error_handler
 
     def create_connect_args(self, url):
-        """ Return a tuple of *args,**kwargs for creating a connection.
+        r"""Return a tuple of \*args, \**kwargs for creating a connection.
 
         The mxODBC 3.x connection constructor looks like this:
 
index 8f5eea89b8eaa7cfe78310053be5654443240807..6c96661a0cd63c5ed94e512352d6d395c039be8e 100644 (file)
@@ -5,13 +5,12 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
+import re
+
 from . import Connector
 from .. import util
 
 
-import re
-
-
 class PyODBCConnector(Connector):
     driver = "pyodbc"
 
index 003ecbed1caf09ab5cf42772b0f4fb41faf04af6..a017f7d13121736fa46071675eadceb553098117 100644 (file)
@@ -6,6 +6,7 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 import sys
+
 from . import Connector
 
 
index d2d56a7ae2ae6a620fb8d63d7d928b55c47204b9..a30e78416c88076cb0063fb5a439eb6308010de3 100644 (file)
@@ -9,17 +9,18 @@
 compatibility with pre 0.6 versions.
 
 """
-from ..dialects.sqlite import base as sqlite
-from ..dialects.postgresql import base as postgresql
-
-postgres = postgresql
-from ..dialects.mysql import base as mysql
-from ..dialects.oracle import base as oracle
 from ..dialects.firebird import base as firebird
 from ..dialects.mssql import base as mssql
+from ..dialects.mysql import base as mysql
+from ..dialects.oracle import base as oracle
+from ..dialects.postgresql import base as postgresql
+from ..dialects.sqlite import base as sqlite
 from ..dialects.sybase import base as sybase
 
 
+postgres = postgresql
+
+
 __all__ = (
     "firebird",
     "mssql",
index 65f30bb7685dc89407e070e69535ce739e22225e..0f11cb0f06cbb18b3cb3e24e490438a0a3e11ffb 100644 (file)
@@ -17,6 +17,7 @@ __all__ = (
 
 from .. import util
 
+
 _translates = {"postgres": "postgresql"}
 
 
index 510d623374735efb8bd64588aa27993dc46175e3..b8de5f0d419df3ee604ca819301f882e623eda08 100644 (file)
@@ -5,21 +5,21 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import base, kinterbasdb, fdb  # noqa
+from sqlalchemy.dialects.firebird.base import BIGINT
+from sqlalchemy.dialects.firebird.base import BLOB
+from sqlalchemy.dialects.firebird.base import CHAR
+from sqlalchemy.dialects.firebird.base import DATE
+from sqlalchemy.dialects.firebird.base import FLOAT
+from sqlalchemy.dialects.firebird.base import NUMERIC
+from sqlalchemy.dialects.firebird.base import SMALLINT
+from sqlalchemy.dialects.firebird.base import TEXT
+from sqlalchemy.dialects.firebird.base import TIME
+from sqlalchemy.dialects.firebird.base import TIMESTAMP
+from sqlalchemy.dialects.firebird.base import VARCHAR
+from . import base  # noqa
+from . import fdb  # noqa
+from . import kinterbasdb  # noqa
 
-from sqlalchemy.dialects.firebird.base import (
-    SMALLINT,
-    BIGINT,
-    FLOAT,
-    DATE,
-    TIME,
-    TEXT,
-    NUMERIC,
-    TIMESTAMP,
-    VARCHAR,
-    CHAR,
-    BLOB,
-)
 
 base.dialect = dialect = fdb.dialect
 
index 1e9c778f3e119857eb3c900582707e9b603721df..70bec8bd939cd4e95b351f7e0b7f862a0f32c98c 100644 (file)
@@ -72,26 +72,26 @@ the SQLAlchemy ``returning()`` method, such as::
 
 import datetime
 
-from sqlalchemy import schema as sa_schema
-from sqlalchemy import exc, types as sqltypes, sql, util
-from sqlalchemy.sql import expression
-from sqlalchemy.engine import base, default, reflection
+from sqlalchemy import exc
+from sqlalchemy import sql
+from sqlalchemy import types as sqltypes
+from sqlalchemy import util
+from sqlalchemy.engine import default
+from sqlalchemy.engine import reflection
 from sqlalchemy.sql import compiler
+from sqlalchemy.sql import expression
 from sqlalchemy.sql.elements import quoted_name
-
-from sqlalchemy.types import (
-    BIGINT,
-    BLOB,
-    DATE,
-    FLOAT,
-    INTEGER,
-    NUMERIC,
-    SMALLINT,
-    TEXT,
-    TIME,
-    TIMESTAMP,
-    Integer,
-)
+from sqlalchemy.types import BIGINT
+from sqlalchemy.types import BLOB
+from sqlalchemy.types import DATE
+from sqlalchemy.types import FLOAT
+from sqlalchemy.types import INTEGER
+from sqlalchemy.types import Integer
+from sqlalchemy.types import NUMERIC
+from sqlalchemy.types import SMALLINT
+from sqlalchemy.types import TEXT
+from sqlalchemy.types import TIME
+from sqlalchemy.types import TIMESTAMP
 
 
 RESERVED_WORDS = set(
@@ -547,11 +547,11 @@ class FBDDLCompiler(sql.compiler.DDLCompiler):
         # no syntax for these
         # http://www.firebirdsql.org/manual/generatorguide-sqlsyntax.html
         if create.element.start is not None:
-            raise NotImplemented(
+            raise NotImplementedError(
                 "Firebird SEQUENCE doesn't support START WITH"
             )
         if create.element.increment is not None:
-            raise NotImplemented(
+            raise NotImplementedError(
                 "Firebird SEQUENCE doesn't support INCREMENT BY"
             )
 
@@ -659,9 +659,9 @@ class FBDialect(default.DefaultDialect):
         name = name and name.rstrip()
         if name is None:
             return None
-        elif name.upper() == name and not self.identifier_preparer._requires_quotes(
-            name.lower()
-        ):
+        elif name.upper() == name and not (
+            self.identifier_preparer._requires_quotes
+        )(name.lower()):
             return name.lower()
         elif name.lower() == name:
             return quoted_name(name, quote=True)
@@ -671,9 +671,9 @@ class FBDialect(default.DefaultDialect):
     def denormalize_name(self, name):
         if name is None:
             return None
-        elif name.lower() == name and not self.identifier_preparer._requires_quotes(
-            name.lower()
-        ):
+        elif name.lower() == name and not (
+            self.identifier_preparer._requires_quotes
+        )(name.lower()):
             return name.upper()
         else:
             return name
index 5bf3d2c49b23258b6ede4b53029c81ef246734d5..83ca5221b1aee8df41b7bf562ff05de65d1ecda7 100644 (file)
@@ -9,8 +9,7 @@
 .. dialect:: firebird+fdb
     :name: fdb
     :dbapi: pyodbc
-    :connectstring: firebird+fdb://user:password@host:port/path/to/db\
-[?key=value&key=value...]
+    :connectstring: firebird+fdb://user:password@host:port/path/to/db[?key=value&key=value...]
     :url: http://pypi.python.org/pypi/fdb/
 
     fdb is a kinterbasdb compatible DBAPI for Firebird.
@@ -66,7 +65,7 @@ accept every argument that Kinterbasdb does.
     http://pythonhosted.org/fdb/usage-guide.html#retaining-transactions
     - information on the "retaining" flag.
 
-"""
+"""  # noqa
 
 from .kinterbasdb import FBDialect_kinterbasdb
 from ... import util
index 6d71440966b5a39bde36d75a9e7bc880ef4046e9..8adce847e841992d724897e18f398d1bb1922b87 100644 (file)
@@ -9,8 +9,7 @@
 .. dialect:: firebird+kinterbasdb
     :name: kinterbasdb
     :dbapi: kinterbasdb
-    :connectstring: firebird+kinterbasdb://user:password@host:port/path/to/db\
-[?key=value&key=value...]
+    :connectstring: firebird+kinterbasdb://user:password@host:port/path/to/db[?key=value&key=value...]
     :url: http://firebirdsql.org/index.php?op=devel&sub=python
 
 Arguments
@@ -36,12 +35,15 @@ In addition, it also accepts the following:
 
     http://kinterbasdb.sourceforge.net/dist_docs/usage.html#special_issue_concurrency
 
-"""
+"""  # noqa
 
-from .base import FBDialect, FBExecutionContext
-from ... import util, types as sqltypes
-from re import match
 import decimal
+from re import match
+
+from .base import FBDialect
+from .base import FBExecutionContext
+from ... import types as sqltypes
+from ... import util
 
 
 class _kinterbasdb_numeric(object):
index 88a94fcfb55d4ee8f14d5dd0eeccd1229c20176f..5bf822bca8d2e63785457cb35ba2fa49815986b8 100644 (file)
@@ -5,41 +5,44 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import base, pyodbc, adodbapi, pymssql, zxjdbc, mxodbc  # noqa
+from . import adodbapi  # noqa
+from . import base  # noqa
+from . import mxodbc  # noqa
+from . import pymssql  # noqa
+from . import pyodbc  # noqa
+from . import zxjdbc  # noqa
+from .base import BIGINT
+from .base import BINARY
+from .base import BIT
+from .base import CHAR
+from .base import DATE
+from .base import DATETIME
+from .base import DATETIME2
+from .base import DATETIMEOFFSET
+from .base import DECIMAL
+from .base import FLOAT
+from .base import IMAGE
+from .base import INTEGER
+from .base import MONEY
+from .base import NCHAR
+from .base import NTEXT
+from .base import NUMERIC
+from .base import NVARCHAR
+from .base import REAL
+from .base import ROWVERSION
+from .base import SMALLDATETIME
+from .base import SMALLINT
+from .base import SMALLMONEY
+from .base import SQL_VARIANT
+from .base import TEXT
+from .base import TIME
+from .base import TIMESTAMP
+from .base import TINYINT
+from .base import UNIQUEIDENTIFIER
+from .base import VARBINARY
+from .base import VARCHAR
+from .base import XML
 
-from .base import (
-    INTEGER,
-    BIGINT,
-    SMALLINT,
-    TINYINT,
-    VARCHAR,
-    NVARCHAR,
-    CHAR,
-    NCHAR,
-    TEXT,
-    NTEXT,
-    DECIMAL,
-    NUMERIC,
-    FLOAT,
-    DATETIME,
-    DATETIME2,
-    DATETIMEOFFSET,
-    DATE,
-    TIME,
-    SMALLDATETIME,
-    BINARY,
-    VARBINARY,
-    BIT,
-    REAL,
-    IMAGE,
-    TIMESTAMP,
-    ROWVERSION,
-    MONEY,
-    SMALLMONEY,
-    UNIQUEIDENTIFIER,
-    SQL_VARIANT,
-    XML,
-)
 
 base.dialect = dialect = pyodbc.dialect
 
index d985c3bb691103ad1293b6fbb43b8db1a3d8205d..08f7ae28ad1aeddc05d016da8deff122d1511170 100644 (file)
 
 """
 import datetime
-from sqlalchemy import types as sqltypes, util
-from sqlalchemy.dialects.mssql.base import MSDateTime, MSDialect
 import sys
 
+from sqlalchemy import types as sqltypes
+from sqlalchemy import util
+from sqlalchemy.dialects.mssql.base import MSDateTime
+from sqlalchemy.dialects.mssql.base import MSDialect
+
 
 class MSDateTime_adodbapi(MSDateTime):
     def result_processor(self, dialect, coltype):
index 161297015fc27ce45526438b38adf206779ff411..ac427b5fd289298450aa564f129435830182fad9 100644 (file)
@@ -4,7 +4,6 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
-
 """
 .. dialect:: mssql
     :name: Microsoft SQL Server
@@ -331,9 +330,10 @@ for these types will be issued as DATETIME.
 Large Text/Binary Type Deprecation
 ----------------------------------
 
-Per `SQL Server 2012/2014 Documentation <http://technet.microsoft.com/en-us/library/ms187993.aspx>`_,
-the ``NTEXT``, ``TEXT`` and ``IMAGE`` datatypes are to be removed from SQL Server
-in a future release.   SQLAlchemy normally relates these types to the
+Per
+`SQL Server 2012/2014 Documentation <http://technet.microsoft.com/en-us/library/ms187993.aspx>`_,
+the ``NTEXT``, ``TEXT`` and ``IMAGE`` datatypes are to be removed from SQL
+Server in a future release.   SQLAlchemy normally relates these types to the
 :class:`.UnicodeText`, :class:`.Text` and :class:`.LargeBinary` datatypes.
 
 In order to accommodate this change, a new flag ``deprecate_large_types``
@@ -355,9 +355,9 @@ behavior of this flag is as follows:
   established.   If the dialect is used to render DDL without the flag being
   set, it is interpreted the same as ``False``.
 
-* On first connection, the dialect detects if SQL Server version 2012 or greater
-  is in use; if the flag is still at ``None``, it sets it to ``True`` or
-  ``False`` based on whether 2012 or greater is detected.
+* On first connection, the dialect detects if SQL Server version 2012 or
+  greater is in use; if the flag is still at ``None``, it sets it to ``True``
+  or ``False`` based on whether 2012 or greater is detected.
 
 * The flag can be set to either ``True`` or ``False`` when the dialect
   is created, typically via :func:`.create_engine`::
@@ -368,8 +368,8 @@ behavior of this flag is as follows:
 * Complete control over whether the "old" or "new" types are rendered is
   available in all SQLAlchemy versions by using the UPPERCASE type objects
   instead: :class:`.NVARCHAR`, :class:`.VARCHAR`, :class:`.types.VARBINARY`,
-  :class:`.TEXT`, :class:`.mssql.NTEXT`, :class:`.mssql.IMAGE` will always remain
-  fixed and always output exactly that type.
+  :class:`.TEXT`, :class:`.mssql.NTEXT`, :class:`.mssql.IMAGE` will always
+  remain fixed and always output exactly that type.
 
 .. versionadded:: 1.0.0
 
@@ -643,38 +643,42 @@ following ALTER DATABASE commands executed at the SQL prompt::
 Background on SQL Server snapshot isolation is available at
 http://msdn.microsoft.com/en-us/library/ms175095.aspx.
 
+"""  # noqa
 
-"""
 import codecs
 import datetime
 import operator
 import re
 
-from ... import sql, schema as sa_schema, exc, util
-from ...sql import compiler, expression, util as sql_util, quoted_name
+from . import information_schema as ischema
 from ... import engine
-from ...engine import reflection, default
+from ... import exc
+from ... import schema as sa_schema
+from ... import sql
 from ... import types as sqltypes
-from ...types import (
-    INTEGER,
-    BIGINT,
-    SMALLINT,
-    DECIMAL,
-    NUMERIC,
-    FLOAT,
-    DATETIME,
-    DATE,
-    BINARY,
-    TEXT,
-    VARCHAR,
-    NVARCHAR,
-    CHAR,
-    NCHAR,
-)
-
-
+from ... import util
+from ...engine import default
+from ...engine import reflection
+from ...sql import compiler
+from ...sql import expression
+from ...sql import quoted_name
+from ...sql import util as sql_util
+from ...types import BIGINT
+from ...types import BINARY
+from ...types import CHAR
+from ...types import DATE
+from ...types import DATETIME
+from ...types import DECIMAL
+from ...types import FLOAT
+from ...types import INTEGER
+from ...types import NCHAR
+from ...types import NUMERIC
+from ...types import NVARCHAR
+from ...types import SMALLINT
+from ...types import TEXT
+from ...types import VARCHAR
 from ...util import update_wrapper
-from . import information_schema as ischema
+
 
 # http://sqlserverbuilds.blogspot.com/
 MS_2016_VERSION = (13,)
@@ -1357,9 +1361,9 @@ class MSExecutionContext(default.DefaultExecutionContext):
             insert_has_sequence = seq_column is not None
 
             if insert_has_sequence:
-                self._enable_identity_insert = seq_column.key in self.compiled_parameters[
-                    0
-                ] or (
+                self._enable_identity_insert = (
+                    seq_column.key in self.compiled_parameters[0]
+                ) or (
                     self.compiled.statement.parameters
                     and (
                         (
@@ -2462,7 +2466,7 @@ class MSDialect(default.DefaultDialect):
                 break
             (
                 name,
-                type,
+                type_,
                 nullable,
                 charlen,
                 numericprec,
@@ -2479,7 +2483,7 @@ class MSDialect(default.DefaultDialect):
                 row[columns.c.column_default],
                 row[columns.c.collation_name],
             )
-            coltype = self.ischema_names.get(type, None)
+            coltype = self.ischema_names.get(type_, None)
 
             kwargs = {}
             if coltype in (
@@ -2501,7 +2505,8 @@ class MSDialect(default.DefaultDialect):
 
             if coltype is None:
                 util.warn(
-                    "Did not recognize type '%s' of column '%s'" % (type, name)
+                    "Did not recognize type '%s' of column '%s'"
+                    % (type_, name)
                 )
                 coltype = sqltypes.NULLTYPE
             else:
index c4ea8ab0cb168900d4b7ec5414e30bebce4291a3..0ff40218e27e81b67bc1558021f631e655796838 100644 (file)
@@ -8,12 +8,18 @@
 # TODO: should be using the sys. catalog with SQL Server, not information
 # schema
 
-from ... import Table, MetaData, Column
-from ...types import String, Unicode, UnicodeText, Integer, TypeDecorator
 from ... import cast
+from ... import Column
+from ... import MetaData
+from ... import Table
 from ... import util
-from ...sql import expression
 from ...ext.compiler import compiles
+from ...sql import expression
+from ...types import Integer
+from ...types import String
+from ...types import TypeDecorator
+from ...types import Unicode
+
 
 ischema = MetaData()
 
index 3b9ea27077ec940ea7ff429d463ff9e96f1de540..6d81e8e497bdf1a4aca5ac2d928d3c3e460bfba7 100644 (file)
@@ -43,17 +43,15 @@ of ``False`` will unconditionally use string-escaped parameters.
 """
 
 
+from .base import _MSDate
+from .base import _MSDateTime
+from .base import _MSTime
+from .base import MSDialect
+from .base import VARBINARY
+from .pyodbc import _MSNumeric_pyodbc
+from .pyodbc import MSExecutionContext_pyodbc
 from ... import types as sqltypes
 from ...connectors.mxodbc import MxODBCConnector
-from .pyodbc import MSExecutionContext_pyodbc, _MSNumeric_pyodbc
-from .base import (
-    MSDialect,
-    MSSQLStrictCompiler,
-    VARBINARY,
-    _MSDateTime,
-    _MSDate,
-    _MSTime,
-)
 
 
 class _MSNumeric_mxodbc(_MSNumeric_pyodbc):
index 847c00329239c65dc2d2cd43867582753ec5d311..062c811ba25c6a076c543bb6198a02e01c35073b 100644 (file)
@@ -9,8 +9,7 @@
 .. dialect:: mssql+pymssql
     :name: pymssql
     :dbapi: pymssql
-    :connectstring: mssql+pymssql://<username>:<password>@<freetds_name>/?\
-charset=utf8
+    :connectstring: mssql+pymssql://<username>:<password>@<freetds_name>/?charset=utf8
     :url: http://pymssql.org/
 
 pymssql is a Python module that provides a Python DBAPI interface around
@@ -20,11 +19,15 @@ Linux, MacOSX and Windows platforms.
 Modern versions of this driver work very well with SQL Server and
 FreeTDS from Linux and is highly recommended.
 
-"""
-from .base import MSDialect, MSIdentifierPreparer
-from ... import types as sqltypes, util, processors
+"""  # noqa
 import re
 
+from .base import MSDialect
+from .base import MSIdentifierPreparer
+from ... import processors
+from ... import types as sqltypes
+from ... import util
+
 
 class _MSNumeric_pymssql(sqltypes.Numeric):
     def result_processor(self, dialect, type_):
index db5573c2c7c20e4aa155b2549cc7489dd1982256..c2d475b1013fd1351e64bd03dfe28c81ce4daa0b 100644 (file)
@@ -55,8 +55,8 @@ Pass through exact Pyodbc string
 
 A PyODBC connection string can also be sent exactly as specified in
 `ConnectionStrings <https://code.google.com/p/pyodbc/wiki/ConnectionStrings>`_
-into the driver using the parameter ``odbc_connect``.  The delimeters must be URL escaped, however,
-as illustrated below using ``urllib.quote_plus``::
+into the driver using the parameter ``odbc_connect``.  The delimeters must be
+URL escaped, however, as illustrated below using ``urllib.quote_plus``::
 
     import urllib
     params = urllib.quote_plus("DRIVER={SQL Server Native Client 10.0};SERVER=dagger;DATABASE=test;UID=user;PWD=password")
@@ -107,19 +107,24 @@ in order to use this flag::
 
 .. seealso::
 
-    `fast executemany
-    <https://github.com/mkleehammer/pyodbc/wiki/Features-beyond-the-DB-API#fast_executemany>`_
+    `fast executemany <https://github.com/mkleehammer/pyodbc/wiki/Features-beyond-the-DB-API#fast_executemany>`_
     - on github
 
 
-"""
+"""  # noqa
 
-from .base import MSExecutionContext, MSDialect, BINARY, VARBINARY
-from ...connectors.pyodbc import PyODBCConnector
-from ... import types as sqltypes, util, exc
 import decimal
 import re
 
+from .base import BINARY
+from .base import MSDialect
+from .base import MSExecutionContext
+from .base import VARBINARY
+from ... import exc
+from ... import types as sqltypes
+from ... import util
+from ...connectors.pyodbc import PyODBCConnector
+
 
 class _ms_numeric_pyodbc(object):
 
index 13fc46e19001f5fa1a25093474f9dc75b7eb708b..8ef74f2d8f86a49e2ebca65a5640cd625c14bc2b 100644 (file)
@@ -9,17 +9,17 @@
 .. dialect:: mssql+zxjdbc
     :name: zxJDBC for Jython
     :dbapi: zxjdbc
-    :connectstring: mssql+zxjdbc://user:pass@host:port/dbname\
-[?key=value&key=value...]
+    :connectstring: mssql+zxjdbc://user:pass@host:port/dbname[?key=value&key=value...]
     :driverurl: http://jtds.sourceforge.net/
 
     .. note:: Jython is not supported by current versions of SQLAlchemy.  The
        zxjdbc dialect should be considered as experimental.
 
-"""
-from ...connectors.zxJDBC import ZxJDBCConnector
-from .base import MSDialect, MSExecutionContext
+"""  # noqa
+from .base import MSDialect
+from .base import MSExecutionContext
 from ... import engine
+from ...connectors.zxJDBC import ZxJDBCConnector
 
 
 class MSExecutionContext_zxjdbc(MSExecutionContext):
index ffeb8f486b0b521eb2254e00257cb1ce1e5286f9..65a30a5b23f01626ccda325db3cdc6da31ee7b4c 100644 (file)
@@ -5,58 +5,52 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import (
-    base,
-    mysqldb,
-    oursql,
-    pyodbc,
-    zxjdbc,
-    mysqlconnector,
-    pymysql,
-    gaerdbms,
-    cymysql,
-)
-
-from .base import (
-    BIGINT,
-    BINARY,
-    BIT,
-    BLOB,
-    BOOLEAN,
-    CHAR,
-    DATE,
-    DATETIME,
-    DECIMAL,
-    DOUBLE,
-    ENUM,
-    DECIMAL,
-    FLOAT,
-    INTEGER,
-    INTEGER,
-    JSON,
-    LONGBLOB,
-    LONGTEXT,
-    MEDIUMBLOB,
-    MEDIUMINT,
-    MEDIUMTEXT,
-    NCHAR,
-    NVARCHAR,
-    NUMERIC,
-    SET,
-    SMALLINT,
-    REAL,
-    TEXT,
-    TIME,
-    TIMESTAMP,
-    TINYBLOB,
-    TINYINT,
-    TINYTEXT,
-    VARBINARY,
-    VARCHAR,
-    YEAR,
-)
+from . import base  # noqa
+from . import cymysql  # noqa
+from . import gaerdbms  # noqa
+from . import mysqlconnector  # noqa
+from . import mysqldb  # noqa
+from . import oursql  # noqa
+from . import pymysql  # noqa
+from . import pyodbc  # noqa
+from . import zxjdbc  # noqa
+from .base import BIGINT
+from .base import BINARY
+from .base import BIT
+from .base import BLOB
+from .base import BOOLEAN
+from .base import CHAR
+from .base import DATE
+from .base import DATETIME
+from .base import DECIMAL
+from .base import DOUBLE
+from .base import ENUM
+from .base import FLOAT
+from .base import INTEGER
+from .base import JSON
+from .base import LONGBLOB
+from .base import LONGTEXT
+from .base import MEDIUMBLOB
+from .base import MEDIUMINT
+from .base import MEDIUMTEXT
+from .base import NCHAR
+from .base import NUMERIC
+from .base import NVARCHAR
+from .base import REAL
+from .base import SET
+from .base import SMALLINT
+from .base import TEXT
+from .base import TIME
+from .base import TIMESTAMP
+from .base import TINYBLOB
+from .base import TINYINT
+from .base import TINYTEXT
+from .base import VARBINARY
+from .base import VARCHAR
+from .base import YEAR
+from .dml import Insert
+from .dml import insert
 
-from .dml import insert, Insert
 
 # default dialect
 base.dialect = dialect = mysqldb.dialect
@@ -100,4 +94,6 @@ __all__ = (
     "VARCHAR",
     "YEAR",
     "dialect",
+    "insert",
+    "Insert",
 )
index 7b0d0618c757dc74baea446666eead03f164650e..4a0d82fe155102469197316ec15d6f9346b4f4e6 100644 (file)
@@ -118,14 +118,13 @@ to be used.
 Transaction Isolation Level
 ---------------------------
 
-All MySQL dialects support setting of transaction isolation level
-both via a dialect-specific parameter :paramref:`.create_engine.isolation_level`
-accepted by :func:`.create_engine`,
-as well as the :paramref:`.Connection.execution_options.isolation_level`
-argument as passed to :meth:`.Connection.execution_options`.
-This feature works by issuing the command
-``SET SESSION TRANSACTION ISOLATION LEVEL <level>`` for
-each new connection.  For the special AUTOCOMMIT isolation level, DBAPI-specific
+All MySQL dialects support setting of transaction isolation level both via a
+dialect-specific parameter :paramref:`.create_engine.isolation_level` accepted
+by :func:`.create_engine`, as well as the
+:paramref:`.Connection.execution_options.isolation_level` argument as passed to
+:meth:`.Connection.execution_options`. This feature works by issuing the
+command ``SET SESSION TRANSACTION ISOLATION LEVEL <level>`` for each new
+connection.  For the special AUTOCOMMIT isolation level, DBAPI-specific
 techniques are used.
 
 To set isolation level using :func:`.create_engine`::
@@ -258,31 +257,35 @@ emit a warning when attempting to pass binary data to the database, while a
 character set encoding is also in place, when the binary data itself is not
 valid for that encoding::
 
-    default.py:509: Warning: (1300, "Invalid utf8mb4 character string: 'F9876A'")
+    default.py:509: Warning: (1300, "Invalid utf8mb4 character string:
+    'F9876A'")
       cursor.execute(statement, parameters)
 
 This warning is due to the fact that the MySQL client library is attempting to
-interpret the binary string as a unicode object even if a datatype such as
-:class:`.LargeBinary` is in use.   To resolve this, the SQL statement requires
+interpret the binary string as a unicode object even if a datatype such
+as :class:`.LargeBinary` is in use.   To resolve this, the SQL statement requires
 a binary "character set introducer" be present before any non-NULL value
 that renders like this::
 
     INSERT INTO table (data) VALUES (_binary %s)
 
-These character set introducers are provided by the DBAPI driver, assuming
-the use of mysqlclient or PyMySQL (both of which are recommended).  Add the
-query string parameter ``binary_prefix=true`` to the URL to repair this warning::
+These character set introducers are provided by the DBAPI driver, assuming the
+use of mysqlclient or PyMySQL (both of which are recommended).  Add the query
+string parameter ``binary_prefix=true`` to the URL to repair this warning::
 
     # mysqlclient
-    engine = create_engine("mysql+mysqldb://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true")
+    engine = create_engine(
+        "mysql+mysqldb://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true")
 
     # PyMySQL
-    engine = create_engine("mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true")
+    engine = create_engine(
+        "mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true")
+
 
 The ``binary_prefix`` flag may or may not be supported by other MySQL drivers.
 
-SQLAlchemy itself cannot render this ``_binary`` prefix reliably, as it does not
-work with the NULL value, which is valid to be sent as a bound parameter.
+SQLAlchemy itself cannot render this ``_binary`` prefix reliably, as it does
+not work with the NULL value, which is valid to be sent as a bound parameter.
 As the MySQL driver renders parameters directly into the SQL string, it's the
 most efficient place for this additional keyword to be passed.
 
@@ -320,7 +323,8 @@ And of course any valid MySQL statement can be executed as a string as well.
 Some limited direct support for MySQL extensions to SQL is currently
 available.
 
-* INSERT..ON DUPLICATE KEY UPDATE:  See :ref:`mysql_insert_on_duplicate_key_update`
+* INSERT..ON DUPLICATE KEY UPDATE:  See
+  :ref:`mysql_insert_on_duplicate_key_update`
 
 * SELECT pragma::
 
@@ -530,8 +534,7 @@ storage engine.
 
 .. seealso::
 
-    `CREATE INDEX <http://dev.mysql.com/doc/refman/5.0/en/create-index.html>`_ - \
-    MySQL documentation
+    `CREATE INDEX <http://dev.mysql.com/doc/refman/5.0/en/create-index.html>`_ - MySQL documentation
 
 Index Types
 ~~~~~~~~~~~~~
@@ -696,8 +699,8 @@ any other datatype on the MySQL side with regards to defaults and nullability.
 
 However, to accommodate the vast majority of MySQL databases that do not
 specify this new flag, SQLAlchemy emits the "NULL" specifier explicitly with
-any TIMESTAMP column that does not specify ``nullable=False``.   In order
-to accommodate newer databases that specify ``explicit_defaults_for_timestamp``,
+any TIMESTAMP column that does not specify ``nullable=False``.   In order to
+accommodate newer databases that specify ``explicit_defaults_for_timestamp``,
 SQLAlchemy also emits NOT NULL for TIMESTAMP columns that do specify
 ``nullable=False``.   The following example illustrates::
 
@@ -731,61 +734,66 @@ output::
    ``explicit_defaults_for_timestamp``.  Prior to this version, it will
    not render "NOT NULL" for a TIMESTAMP column that is ``nullable=False``.
 
-"""
+"""  # noqa
 
+from array import array as _array
 from collections import defaultdict
 import re
 import sys
 
+from . import reflection as _reflection
+from .enumerated import ENUM
+from .enumerated import SET
+from .json import JSON
+from .json import JSONIndexType
+from .json import JSONPathType
+from .types import _FloatType
+from .types import _IntegerType
+from .types import _MatchType
+from .types import _NumericType
+from .types import _StringType
+from .types import BIGINT
+from .types import BIT
+from .types import CHAR
+from .types import DATETIME
+from .types import DECIMAL
+from .types import DOUBLE
+from .types import FLOAT
+from .types import INTEGER
+from .types import LONGBLOB
+from .types import LONGTEXT
+from .types import MEDIUMBLOB
+from .types import MEDIUMINT
+from .types import MEDIUMTEXT
+from .types import NCHAR
+from .types import NUMERIC
+from .types import NVARCHAR
+from .types import REAL
+from .types import SMALLINT
+from .types import TEXT
+from .types import TIME
+from .types import TIMESTAMP
+from .types import TINYBLOB
+from .types import TINYINT
+from .types import TINYTEXT
+from .types import VARCHAR
+from .types import YEAR
+from ... import exc
+from ... import log
 from ... import schema as sa_schema
-from ... import exc, log, sql, util
-from ...sql import compiler, elements
-from array import array as _array
-
-from ...engine import reflection
-from ...engine import default
+from ... import sql
 from ... import types as sqltypes
+from ... import util
+from ...engine import default
+from ...engine import reflection
+from ...sql import compiler
+from ...sql import elements
+from ...types import BINARY
+from ...types import BLOB
+from ...types import BOOLEAN
+from ...types import DATE
+from ...types import VARBINARY
 from ...util import topological
-from ...types import DATE, BOOLEAN, BLOB, BINARY, VARBINARY
-
-from . import reflection as _reflection
-from .types import (
-    BIGINT,
-    BIT,
-    CHAR,
-    DECIMAL,
-    DATETIME,
-    DOUBLE,
-    FLOAT,
-    INTEGER,
-    LONGBLOB,
-    LONGTEXT,
-    MEDIUMBLOB,
-    MEDIUMINT,
-    MEDIUMTEXT,
-    NCHAR,
-    NUMERIC,
-    NVARCHAR,
-    REAL,
-    SMALLINT,
-    TEXT,
-    TIME,
-    TIMESTAMP,
-    TINYBLOB,
-    TINYINT,
-    TINYTEXT,
-    VARCHAR,
-    YEAR,
-)
-from .types import (
-    _StringType,
-    _IntegerType,
-    _NumericType,
-    _FloatType,
-    _MatchType,
-)
-from .enumerated import ENUM, SET
-from .json import JSON, JSONIndexType, JSONPathType
 
 
 RESERVED_WORDS = set(
@@ -2026,7 +2034,7 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
             "SET", type_, type_._enumerated_values
         )
 
-    def visit_BOOLEAN(self, type, **kw):
+    def visit_BOOLEAN(self, type_, **kw):
         return "BOOL"
 
 
index 8a60608db76f96757bd857f94a7e8a7459398c2f..ba7c6fac2685123f02a0abe2d339387a132e6762 100644 (file)
@@ -4,21 +4,19 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
-
-"""
+r"""
 
 .. dialect:: mysql+cymysql
     :name: CyMySQL
     :dbapi: cymysql
-    :connectstring: mysql+cymysql://<username>:<password>@<host>/<dbname>\
-[?<options>]
+    :connectstring: mysql+cymysql://<username>:<password>@<host>/<dbname>[?<options>]
     :url: https://github.com/nakagami/CyMySQL
 
-"""
-import re
+"""  # noqa
 
+from .base import BIT
+from .base import MySQLDialect
 from .mysqldb import MySQLDialect_mysqldb
-from .base import BIT, MySQLDialect
 from ... import util
 
 
index 5d59b2073ecfa6e67df134b596955b1a0030cbd6..59cd22d36557426377d03bf973bb939a2898b6a1 100644 (file)
@@ -1,10 +1,11 @@
-from ...sql.elements import ClauseElement
+from ... import exc
+from ... import util
+from ...sql.base import _generative
 from ...sql.dml import Insert as StandardInsert
+from ...sql.elements import ClauseElement
 from ...sql.expression import alias
 from ...util.langhelpers import public_factory
-from ...sql.base import _generative
-from ... import exc
-from ... import util
+
 
 __all__ = ("Insert", "insert")
 
index 9586eff3fffaaa6d0ee27258f156fc360727233c..fe42bb3aa58a74c3d7b254c57f5228d637686775 100644 (file)
@@ -8,7 +8,9 @@
 import re
 
 from .types import _StringType
-from ... import exc, sql, util
+from ... import exc
+from ... import sql
+from ... import util
 from ...sql import sqltypes
 
 
index 117cd28a2f803b17ee4a2b92d668848fa05908df..23c84ec15f432e60e6bac2cdf9af7dd17c85fb80 100644 (file)
@@ -4,13 +4,12 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
+r"""
 .. dialect:: mysql+gaerdbms
     :name: Google Cloud SQL
     :dbapi: rdbms
     :connectstring: mysql+gaerdbms:///<dbname>?instance=<instancename>
-    :url: https://developers.google.com/appengine/docs/python/cloud-sql/\
-developers-guide
+    :url: https://developers.google.com/appengine/docs/python/cloud-sql/developers-guide
 
     This dialect is based primarily on the :mod:`.mysql.mysqldb` dialect with
     minimal changes.
@@ -33,14 +32,14 @@ so the dialect does not pool connections.  The :class:`.NullPool`
 implementation is installed within the :class:`.Engine` by
 default.
 
-"""
+"""  # noqa
 
 import os
+import re
 
+from sqlalchemy.util import warn_deprecated
 from .mysqldb import MySQLDialect_mysqldb
 from ...pool import NullPool
-import re
-from sqlalchemy.util import warn_deprecated
 
 
 def _is_dev_environment():
index 162d48f73ba5c1eae03692b76f92a2893b61c93c..0f2ca439f870bfb45342123a54cdee1df0428e22 100644 (file)
@@ -7,9 +7,7 @@
 
 from __future__ import absolute_import
 
-from ...sql import elements
 from ... import types as sqltypes
-from ... import util
 
 
 class JSON(sqltypes.JSON):
index 9c1502a14b2fb273d5f2a4a44a646592dd1ae29a..3e2211060c055e04273274b7514b5a5e170179e2 100644 (file)
@@ -5,12 +5,11 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-"""
+r"""
 .. dialect:: mysql+mysqlconnector
     :name: MySQL Connector/Python
     :dbapi: myconnpy
-    :connectstring: mysql+mysqlconnector://<user>:<password>@\
-<host>[:<port>]/<dbname>
+    :connectstring: mysql+mysqlconnector://<user>:<password>@<host>[:<port>]/<dbname>
     :url: http://dev.mysql.com/downloads/connector/python/
 
 
@@ -45,19 +44,17 @@ This list should be updated as these issues are resolved either in the
 upstream mysql-connector-python driver or if appropriate usage patterns
 are contributed to SQLAlchemy.
 
-"""
+"""  # noqa
 
-from .base import (
-    MySQLDialect,
-    MySQLExecutionContext,
-    MySQLCompiler,
-    MySQLIdentifierPreparer,
-    BIT,
-)
-
-from ... import util
 import re
+
+from .base import BIT
+from .base import MySQLCompiler
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from .base import MySQLIdentifierPreparer
 from ... import processors
+from ... import util
 
 
 class MySQLExecutionContext_mysqlconnector(MySQLExecutionContext):
@@ -140,9 +137,9 @@ class MySQLDialect_mysqlconnector(MySQLDialect):
 
         # hack description encoding since mysqlconnector randomly
         # returns bytes or not
-        self._description_decoder = processors.to_conditional_unicode_processor_factory(
-            self.description_encoding
-        )
+        self._description_decoder = (
+            processors.to_conditional_unicode_processor_factory
+        )(self.description_encoding)
 
     def _check_unicode_description(self, connection):
         # hack description encoding since mysqlconnector randomly
index 6d42f5c04ec993f265a7bc6c6bc3106b0f82f815..313940cbc9c37116dcf071428cac68c381d4d4c4 100644 (file)
@@ -45,16 +45,15 @@ The mysqldb dialect supports server-side cursors. See :ref:`mysql_ss_cursors`.
 
 """
 
-from .base import (
-    MySQLDialect,
-    MySQLExecutionContext,
-    MySQLCompiler,
-    MySQLIdentifierPreparer,
-)
+import re
+
+from .base import MySQLCompiler
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from .base import MySQLIdentifierPreparer
 from .base import TEXT
 from ... import sql
 from ... import util
-import re
 
 
 class MySQLExecutionContext_mysqldb(MySQLExecutionContext):
index 8ba353a31141ab077b3447b076aad48decc1c4e4..560135a404f219b2f271bbada0d7d78ea18898e0 100644 (file)
@@ -22,10 +22,12 @@ handling.
 
 """
 
-import re
 
-from .base import BIT, MySQLDialect, MySQLExecutionContext
-from ... import types as sqltypes, util
+from .base import BIT
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from ... import types as sqltypes
+from ... import util
 
 
 class _oursqlBIT(BIT):
index 94dbfff063bb5d48e60d3c582bd4f171a65f9957..2778a9b2f4ae76e923f995eb7945c70515ae3a3a 100644 (file)
@@ -5,13 +5,12 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-"""
+r"""
 
 .. dialect:: mysql+pymysql
     :name: PyMySQL
     :dbapi: pymysql
-    :connectstring: mysql+pymysql://<username>:<password>@<host>/<dbname>\
-[?<options>]
+    :connectstring: mysql+pymysql://<username>:<password>@<host>/<dbname>[?<options>]
     :url: https://pymysql.readthedocs.io/
 
 Unicode
@@ -27,10 +26,11 @@ The pymysql DBAPI is a pure Python port of the MySQL-python (MySQLdb) driver,
 and targets 100% compatibility.   Most behavioral notes for MySQL-python apply
 to the pymysql driver as well.
 
-"""
+"""  # noqa
 
 from .mysqldb import MySQLDialect_mysqldb
-from ...util import langhelpers, py3k
+from ...util import langhelpers
+from ...util import py3k
 
 
 class MySQLDialect_pymysql(MySQLDialect_mysqldb):
index 91512857eef16a06708d7af9d35abe3bf8c7c14c..736de5f048d7dddc9eb930f9c303b83e16496656 100644 (file)
 
 """
 
-from .base import MySQLDialect, MySQLExecutionContext
-from ...connectors.pyodbc import PyODBCConnector
-from ... import util
 import re
 
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from ... import util
+from ...connectors.pyodbc import PyODBCConnector
+
 
 class MySQLExecutionContext_pyodbc(MySQLExecutionContext):
     def get_lastrowid(self):
index d0513eb4d96a5ce20481b82b2a19cbffa1d14467..87438f460b990753f1b51eb475be5f3bb8cef6ca 100644 (file)
@@ -6,10 +6,15 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 import re
-from ... import log, util
+
+from .enumerated import _EnumeratedValues
+from .enumerated import SET
+from .types import DATETIME
+from .types import TIME
+from .types import TIMESTAMP
+from ... import log
 from ... import types as sqltypes
-from .enumerated import _EnumeratedValues, SET
-from .types import DATETIME, TIME, TIMESTAMP
+from ... import util
 
 
 class ReflectedState(object):
index ad97a9bbe1aa471c01adf5d9862151ae0d6e7a64..a234ddf08bbd15be17e1e103f65cbd2175fd6b0f 100644 (file)
@@ -6,8 +6,10 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 import datetime
-from ... import exc, util
+
+from ... import exc
 from ... import types as sqltypes
+from ... import util
 
 
 class _NumericType(object):
@@ -68,7 +70,7 @@ class _StringType(sqltypes.String):
         self,
         charset=None,
         collation=None,
-        ascii=False,
+        ascii=False,  # noqa
         binary=False,
         unicode=False,
         national=False,
index d8ee437489cd1ddb60ee33ce28b2af9b1b85dbc1..3a4cee7264f0e797afc06ad0d8358da739d87102 100644 (file)
@@ -5,13 +5,12 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-"""
+r"""
 
 .. dialect:: mysql+zxjdbc
     :name: zxjdbc for Jython
     :dbapi: zxjdbc
-    :connectstring: mysql+zxjdbc://<user>:<password>@<hostname>[:<port>]/\
-<database>
+    :connectstring: mysql+zxjdbc://<user>:<password>@<hostname>[:<port>]/<database>
     :driverurl: http://dev.mysql.com/downloads/connector/j/
 
     .. note:: Jython is not supported by current versions of SQLAlchemy.  The
@@ -26,12 +25,15 @@ MySQL Connector/J JDBC driver, by default SQLAlchemy sets its
 ``characterEncoding`` connection property to ``UTF-8``. It may be
 overridden via a ``create_engine`` URL parameter.
 
-"""
+"""  # noqa
 import re
 
-from ... import types as sqltypes, util
+from .base import BIT
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from ... import types as sqltypes
+from ... import util
 from ...connectors.zxJDBC import ZxJDBCConnector
-from .base import BIT, MySQLDialect, MySQLExecutionContext
 
 
 class _ZxJDBCBit(BIT):
index 1b9007fcc7116e50e383f8a5e1d45ddccdbcd8cf..7622bdf1950542ee5d799a6b3f6228ffc7507867 100644 (file)
@@ -5,30 +5,30 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import base, cx_oracle, zxjdbc  # noqa
+from . import base  # noqa
+from . import cx_oracle  # noqa
+from . import zxjdbc  # noqa
+from .base import BFILE
+from .base import BINARY_DOUBLE
+from .base import BINARY_FLOAT
+from .base import BLOB
+from .base import CHAR
+from .base import CLOB
+from .base import DATE
+from .base import DOUBLE_PRECISION
+from .base import FLOAT
+from .base import INTERVAL
+from .base import LONG
+from .base import NCLOB
+from .base import NUMBER
+from .base import NVARCHAR
+from .base import NVARCHAR2
+from .base import RAW
+from .base import ROWID
+from .base import TIMESTAMP
+from .base import VARCHAR
+from .base import VARCHAR2
 
-from .base import (
-    VARCHAR,
-    NVARCHAR,
-    CHAR,
-    DATE,
-    NUMBER,
-    BLOB,
-    BFILE,
-    BINARY_FLOAT,
-    BINARY_DOUBLE,
-    CLOB,
-    NCLOB,
-    TIMESTAMP,
-    RAW,
-    FLOAT,
-    DOUBLE_PRECISION,
-    LONG,
-    INTERVAL,
-    VARCHAR2,
-    NVARCHAR2,
-    ROWID,
-)
 
 base.dialect = dialect = cx_oracle.dialect
 
index 944fe21c369c1f74c5f04680754ca390bfcf622d..b58d038cf389a4aeb48d99b2dc1672536227967d 100644 (file)
@@ -5,7 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-"""
+r"""
 .. dialect:: oracle
     :name: Oracle
 
@@ -343,27 +343,31 @@ columns for non-unique indexes, all but the last column for unique indexes).
 
 .. versionadded:: 1.0.0
 
-"""
+"""  # noqa
 
+from itertools import groupby
 import re
 
-from sqlalchemy import util, sql
-from sqlalchemy.engine import default, reflection
-from sqlalchemy.sql import compiler, visitors, expression, util as sql_util
-from sqlalchemy.sql import operators as sql_operators
-from sqlalchemy.sql.elements import quoted_name
-from sqlalchemy import types as sqltypes, schema as sa_schema
-from sqlalchemy.types import (
-    VARCHAR,
-    NVARCHAR,
-    CHAR,
-    BLOB,
-    CLOB,
-    TIMESTAMP,
-    FLOAT,
-    INTEGER,
-)
-from itertools import groupby
+from ... import schema as sa_schema
+from ... import sql
+from ... import types as sqltypes
+from ... import util
+from ...engine import default
+from ...engine import reflection
+from ...sql import compiler
+from ...sql import expression
+from ...sql import util as sql_util
+from ...sql import visitors
+from ...sql.elements import quoted_name
+from ...types import BLOB
+from ...types import CHAR
+from ...types import CLOB
+from ...types import FLOAT
+from ...types import INTEGER
+from ...types import NVARCHAR
+from ...types import TIMESTAMP
+from ...types import VARCHAR
+
 
 RESERVED_WORDS = set(
     "SHARE RAW DROP BETWEEN FROM DESC OPTION PRIOR LONG THEN "
@@ -1200,9 +1204,9 @@ class OracleDialect(default.DefaultDialect):
         if util.py2k:
             if isinstance(name, str):
                 name = name.decode(self.encoding)
-        if name.upper() == name and not self.identifier_preparer._requires_quotes(
-            name.lower()
-        ):
+        if name.upper() == name and not (
+            self.identifier_preparer._requires_quotes
+        )(name.lower()):
             return name.lower()
         elif name.lower() == name:
             return quoted_name(name, quote=True)
@@ -1212,15 +1216,15 @@ class OracleDialect(default.DefaultDialect):
     def denormalize_name(self, name):
         if name is None:
             return None
-        elif name.lower() == name and not self.identifier_preparer._requires_quotes(
-            name.lower()
-        ):
+        elif name.lower() == name and not (
+            self.identifier_preparer._requires_quotes
+        )(name.lower()):
             name = name.upper()
         if util.py2k:
             if not self.supports_unicode_binds:
                 name = name.encode(self.encoding)
             else:
-                name = unicode(name)
+                name = unicode(name)  # noqa
         return name
 
     def _get_default_schema_name(self, connection):
@@ -1827,7 +1831,12 @@ class OracleDialect(default.DefaultDialect):
 
                 if not rec["referred_table"]:
                     if resolve_synonyms:
-                        ref_remote_name, ref_remote_owner, ref_dblink, ref_synonym = self._resolve_synonym(
+                        (
+                            ref_remote_name,
+                            ref_remote_owner,
+                            ref_dblink,
+                            ref_synonym,
+                        ) = self._resolve_synonym(
                             connection,
                             desired_owner=self.denormalize_name(remote_owner),
                             desired_table=self.denormalize_name(remote_table),
@@ -1882,14 +1891,10 @@ class OracleDialect(default.DefaultDialect):
         unique_keys = filter(lambda x: x[1] == "U", constraint_data)
         uniques_group = groupby(unique_keys, lambda x: x[0])
 
-        index_names = set(
-            [
-                ix["name"]
-                for ix in self.get_indexes(
-                    connection, table_name, schema=schema
-                )
-            ]
-        )
+        index_names = {
+            ix["name"]
+            for ix in self.get_indexes(connection, table_name, schema=schema)
+        }
         return [
             {
                 "name": name,
index 91534c0da2a7fc6cfdfec3571d0cf21f2b6789d9..ba52176a052cf4f6e6ba3a163a2d038864f9f5bc 100644 (file)
@@ -4,13 +4,11 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-"""
-
+r"""
 .. dialect:: oracle+cx_oracle
     :name: cx-Oracle
     :dbapi: cx_oracle
-    :connectstring: oracle+cx_oracle://user:pass@host:port/dbname\
-[?key=value&key=value...]
+    :connectstring: oracle+cx_oracle://user:pass@host:port/dbname[?key=value&key=value...]
     :url: http://cx-oracle.sourceforge.net/
 
 Additional Connect Arguments
@@ -51,7 +49,8 @@ Alternatively, most cx_Oracle DBAPI arguments can also be encoded as strings
 within the URL, which includes parameters such as ``mode``, ``purity``,
 ``events``, ``threaded``, and others::
 
-    e = create_engine("oracle+cx_oracle://user:pass@dsn?mode=SYSDBA&events=true")
+    e = create_engine(
+        "oracle+cx_oracle://user:pass@dsn?mode=SYSDBA&events=true")
 
 .. versionchanged:: 1.3 the cx_oracle dialect now accepts all argument names
    within the URL string itself, to be passed to the cx_Oracle DBAPI.   As
@@ -63,7 +62,8 @@ There are also options that are consumed by the SQLAlchemy cx_oracle dialect
 itself.  These options are always passed directly to :func:`.create_engine`,
 such as::
 
-    e = create_engine("oracle+cx_oracle://user:pass@dsn", coerce_to_unicode=False)
+    e = create_engine(
+        "oracle+cx_oracle://user:pass@dsn", coerce_to_unicode=False)
 
 The parameters accepted by the cx_oracle dialect are as follows:
 
@@ -126,8 +126,8 @@ VARCHAR2, CHAR, and CLOB, the flag ``coerce_to_unicode=False`` can be passed to
 
 .. _cx_oracle_setinputsizes:
 
-Fine grained control over cx_Oracle data binding and performance with setinputsizes
------------------------------------------------------------------------------------
+Fine grained control over cx_Oracle data binding performance with setinputsizes
+-------------------------------------------------------------------------------
 
 The cx_Oracle DBAPI has a deep and fundamental reliance upon the usage of the
 DBAPI ``setinputsizes()`` call.   The purpose of this call is to establish the
@@ -140,13 +140,14 @@ settings can cause profoundly different performance characteristics, while
 altering the type coercion behavior at the same time.
 
 Users of the cx_Oracle dialect are **strongly encouraged** to read through
-cx_Oracle's list of built-in datatype symbols at http://cx-oracle.readthedocs.io/en/latest/module.html#types.
-Note that in some cases, signficant performance degradation can occur when using
-these types vs. not, in particular when specifying ``cx_Oracle.CLOB``.
-
-On the SQLAlchemy side, the :meth:`.DialectEvents.do_setinputsizes` event
-can be used both for runtime visibliity (e.g. logging) of the setinputsizes
-step as well as to fully control how ``setinputsizes()`` is used on a per-statement
+cx_Oracle's list of built-in datatype symbols at
+http://cx-oracle.readthedocs.io/en/latest/module.html#types.
+Note that in some cases, signficant performance degradation can occur when
+using these types vs. not, in particular when specifying ``cx_Oracle.CLOB``.
+
+On the SQLAlchemy side, the :meth:`.DialectEvents.do_setinputsizes` event can
+be used both for runtime visibliity (e.g. logging) of the setinputsizes step as
+well as to fully control how ``setinputsizes()`` is used on a per-statement
 basis.
 
 .. versionadded:: 1.2.9 Added :meth:`.DialectEvents.setinputsizes`
@@ -155,8 +156,8 @@ basis.
 Example 1 - logging all setinputsizes calls
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-The following example illustrates how to log the intermediary values from
-SQLAlchemy perspective before they are converted to the raw ``setinputsizes()``
+The following example illustrates how to log the intermediary values from a
+SQLAlchemy perspective before they are converted to the raw ``setinputsizes()``
 parameter dictionary.  The keys of the dictionary are :class:`.BindParameter`
 objects which have a ``.key`` and a ``.type`` attribute::
 
@@ -273,24 +274,31 @@ SQLAlchemy type (or a subclass of such).
    reworked to take advantage of newer cx_Oracle features as well
    as better integration of outputtypehandlers.
 
-"""
+"""  # noqa
 
 from __future__ import absolute_import
 
-from .base import OracleCompiler, OracleDialect, OracleExecutionContext
-from . import base as oracle
-from ...engine import result as _result
-from sqlalchemy import types as sqltypes, util, exc, processors
-from ...util import compat
-import random
 import collections
 import decimal
+import random
 import re
 
+from . import base as oracle
+from .base import OracleCompiler
+from .base import OracleDialect
+from .base import OracleExecutionContext
+from ... import exc
+from ... import processors
+from ... import types as sqltypes
+from ... import util
+from ...engine import result as _result
+from ...util import compat
+
 
 class _OracleInteger(sqltypes.Integer):
     def get_dbapi_type(self, dbapi):
-        # see https://github.com/oracle/python-cx_Oracle/issues/208#issuecomment-409715955
+        # see https://github.com/oracle/python-cx_Oracle/issues/
+        # 208#issuecomment-409715955
         return int
 
     def _cx_oracle_var(self, dialect, cursor):
@@ -642,8 +650,8 @@ class OracleExecutionContext_cx_oracle(OracleExecutionContext):
 
                 for bind, name in self.compiled.bind_names.items():
                     if name in self.out_parameters:
-                        type = bind.type
-                        impl_type = type.dialect_impl(self.dialect)
+                        type_ = bind.type
+                        impl_type = type_.dialect_impl(self.dialect)
                         dbapi_type = impl_type.get_dbapi_type(
                             self.dialect.dbapi
                         )
@@ -1073,8 +1081,8 @@ class OracleDialect_cx_oracle(OracleDialect):
 
         """
 
-        id = random.randint(0, 2 ** 128)
-        return (0x1234, "%032x" % id, "%032x" % 9)
+        id_ = random.randint(0, 2 ** 128)
+        return (0x1234, "%032x" % id_, "%032x" % 9)
 
     def do_executemany(self, cursor, statement, parameters, context=None):
         if isinstance(parameters, tuple):
index 0a365f8b0277688a2ca579e201f297abd31a3663..bcd892aa77a2942955ab10961b3631fbc9cb4f11 100644 (file)
     .. note:: Jython is not supported by current versions of SQLAlchemy.  The
        zxjdbc dialect should be considered as experimental.
 
-"""
+"""  # noqa
+import collections
 import decimal
 import re
 
-from sqlalchemy import sql, types as sqltypes, util
-from sqlalchemy.connectors.zxJDBC import ZxJDBCConnector
-from sqlalchemy.dialects.oracle.base import (
-    OracleCompiler,
-    OracleDialect,
-    OracleExecutionContext,
-)
-from sqlalchemy.engine import result as _result
-from sqlalchemy.sql import expression
-import collections
+from .base import OracleCompiler
+from .base import OracleDialect
+from .base import OracleExecutionContext
+from ... import sql
+from ... import types as sqltypes
+from ... import util
+from ...connectors.zxJDBC import ZxJDBCConnector
+from ...engine import result as _result
+from ...sql import expression
+
 
 SQLException = zxJDBC = None
 
@@ -173,8 +174,8 @@ class ReturningParam(object):
     Specially handled by OracleReturningDataHandler.
     """
 
-    def __init__(self, type):
-        self.type = type
+    def __init__(self, type_):
+        self.type = type_
 
     def __eq__(self, other):
         if isinstance(other, ReturningParam):
@@ -218,16 +219,16 @@ class OracleDialect_zxjdbc(ZxJDBCConnector, OracleDialect):
         class OracleReturningDataHandler(OracleDataHandler):
             """zxJDBC DataHandler that specially handles ReturningParam."""
 
-            def setJDBCObject(self, statement, index, object, dbtype=None):
-                if type(object) is ReturningParam:
-                    statement.registerReturnParameter(index, object.type)
+            def setJDBCObject(self, statement, index, object_, dbtype=None):
+                if type(object_) is ReturningParam:
+                    statement.registerReturnParameter(index, object_.type)
                 elif dbtype is None:
                     OracleDataHandler.setJDBCObject(
-                        self, statement, index, object
+                        self, statement, index, object_
                     )
                 else:
                     OracleDataHandler.setJDBCObject(
-                        self, statement, index, object, dbtype
+                        self, statement, index, object_, dbtype
                     )
 
         self.DataHandler = OracleReturningDataHandler
index 9e65484fa165619ace0b3dfc06ea95ea5c68160b..a269770d1c8b91aa8a41900ac5c7d186803279dc 100644 (file)
@@ -5,60 +5,61 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import (
-    base,
-    psycopg2,
-    pg8000,
-    pypostgresql,
-    pygresql,
-    zxjdbc,
-    psycopg2cffi,
-)  # noqa
+from . import base
+from . import pg8000  # noqa
+from . import psycopg2  # noqa
+from . import psycopg2cffi  # noqa
+from . import pygresql  # noqa
+from . import pypostgresql  # noqa
+from . import zxjdbc  # noqa
+from .array import All
+from .array import Any
+from .array import ARRAY
+from .array import array
+from .base import BIGINT
+from .base import BIT
+from .base import BOOLEAN
+from .base import BYTEA
+from .base import CHAR
+from .base import CIDR
+from .base import CreateEnumType
+from .base import DATE
+from .base import DOUBLE_PRECISION
+from .base import DropEnumType
+from .base import ENUM
+from .base import FLOAT
+from .base import INET
+from .base import INTEGER
+from .base import INTERVAL
+from .base import MACADDR
+from .base import MONEY
+from .base import NUMERIC
+from .base import OID
+from .base import REAL
+from .base import REGCLASS
+from .base import SMALLINT
+from .base import TEXT
+from .base import TIME
+from .base import TIMESTAMP
+from .base import TSVECTOR
+from .base import UUID
+from .base import VARCHAR
+from .dml import Insert
+from .dml import insert
+from .ext import aggregate_order_by
+from .ext import array_agg
+from .ext import ExcludeConstraint
+from .hstore import HSTORE
+from .hstore import hstore
+from .json import JSON
+from .json import JSONB
+from .ranges import DATERANGE
+from .ranges import INT4RANGE
+from .ranges import INT8RANGE
+from .ranges import NUMRANGE
+from .ranges import TSRANGE
+from .ranges import TSTZRANGE
 
-from .base import (
-    INTEGER,
-    BIGINT,
-    SMALLINT,
-    VARCHAR,
-    CHAR,
-    TEXT,
-    NUMERIC,
-    FLOAT,
-    REAL,
-    INET,
-    CIDR,
-    UUID,
-    BIT,
-    MACADDR,
-    MONEY,
-    OID,
-    REGCLASS,
-    DOUBLE_PRECISION,
-    TIMESTAMP,
-    TIME,
-    DATE,
-    BYTEA,
-    BOOLEAN,
-    INTERVAL,
-    ENUM,
-    TSVECTOR,
-    DropEnumType,
-    CreateEnumType,
-)
-from .hstore import HSTORE, hstore
-from .json import JSON, JSONB
-from .array import array, ARRAY, Any, All
-from .ext import aggregate_order_by, ExcludeConstraint, array_agg
-from .dml import insert, Insert
-
-from .ranges import (
-    INT4RANGE,
-    INT8RANGE,
-    NUMRANGE,
-    DATERANGE,
-    TSRANGE,
-    TSTZRANGE,
-)
 
 base.dialect = dialect = psycopg2.dialect
 
@@ -98,6 +99,7 @@ __all__ = (
     "INT8RANGE",
     "NUMRANGE",
     "DATERANGE",
+    "TSVECTOR",
     "TSRANGE",
     "TSTZRANGE",
     "JSON",
index 07167f9d0f9f4468ec4d684fe44fafa115e6ff8a..af1469880f551d70cda30aa267b372c47cb849ff 100644 (file)
@@ -5,13 +5,15 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from .base import ischema_names, colspecs
-from ...sql import expression, operators
-from ...sql.base import SchemaEventTarget
+from .base import colspecs
+from .base import ischema_names
 from ... import types as sqltypes
+from ...sql import expression
+from ...sql import operators
+
 
 try:
-    from uuid import UUID as _python_UUID
+    from uuid import UUID as _python_UUID  # noqa
 except ImportError:
     _python_UUID = None
 
@@ -142,13 +144,14 @@ class ARRAY(sqltypes.ARRAY):
             )
 
     The :class:`.postgresql.ARRAY` type provides all operations defined on the
-    core :class:`.types.ARRAY` type, including support for "dimensions", indexed
-    access, and simple matching such as :meth:`.types.ARRAY.Comparator.any`
-    and :meth:`.types.ARRAY.Comparator.all`.  :class:`.postgresql.ARRAY` class also
+    core :class:`.types.ARRAY` type, including support for "dimensions",
+    indexed access, and simple matching such as
+    :meth:`.types.ARRAY.Comparator.any` and
+    :meth:`.types.ARRAY.Comparator.all`.  :class:`.postgresql.ARRAY` class also
     provides PostgreSQL-specific methods for containment operations, including
     :meth:`.postgresql.ARRAY.Comparator.contains`
-    :meth:`.postgresql.ARRAY.Comparator.contained_by`,
-    and :meth:`.postgresql.ARRAY.Comparator.overlap`, e.g.::
+    :meth:`.postgresql.ARRAY.Comparator.contained_by`, and
+    :meth:`.postgresql.ARRAY.Comparator.overlap`, e.g.::
 
         mytable.c.data.contains([1, 2])
 
index 11833da57382cece6a009d76a43668df26f43612..e77b2880f0d50f7f2a617431c0d6c82fa6e233d1 100644 (file)
@@ -290,13 +290,13 @@ use the :meth:`._UpdateBase.returning` method on a per-statement basis::
 INSERT...ON CONFLICT (Upsert)
 ------------------------------
 
-Starting with version 9.5, PostgreSQL allows "upserts" (update or insert)
-of rows into a table via the ``ON CONFLICT`` clause of the ``INSERT`` statement.
-A candidate row will only be inserted if that row does not violate
-any unique constraints.  In the case of a unique constraint violation,
-a secondary action can occur which can be either "DO UPDATE", indicating
-that the data in the target row should be updated, or "DO NOTHING",
-which indicates to silently skip this row.
+Starting with version 9.5, PostgreSQL allows "upserts" (update or insert) of
+rows into a table via the ``ON CONFLICT`` clause of the ``INSERT`` statement. A
+candidate row will only be inserted if that row does not violate any unique
+constraints.  In the case of a unique constraint violation, a secondary action
+can occur which can be either "DO UPDATE", indicating that the data in the
+target row should be updated, or "DO NOTHING", which indicates to silently skip
+this row.
 
 Conflicts are determined using existing unique constraints and indexes.  These
 constraints may be identified either using their name as stated in DDL,
@@ -331,8 +331,9 @@ Both methods supply the "target" of the conflict using either the
 named constraint or by column inference:
 
 * The :paramref:`.Insert.on_conflict_do_update.index_elements` argument
-  specifies a sequence containing string column names, :class:`.Column` objects,
-  and/or SQL expression elements, which would identify a unique index::
+  specifies a sequence containing string column names, :class:`.Column`
+  objects, and/or SQL expression elements, which would identify a unique
+  index::
 
     do_update_stmt = insert_stmt.on_conflict_do_update(
         index_elements=['id'],
@@ -915,34 +916,37 @@ E.g.::
 
 """
 from collections import defaultdict
-import re
 import datetime as dt
+import re
 
-
-from sqlalchemy.sql import elements
-from ... import sql, schema, exc, util
-from ...engine import default, reflection
-from ...sql import compiler, expression
+from ... import exc
+from ... import schema
+from ... import sql
+from ... import util
+from ...engine import default
+from ...engine import reflection
+from ...sql import compiler
+from ...sql import elements
+from ...sql import expression
 from ...sql import sqltypes
+from ...types import BIGINT
+from ...types import BOOLEAN
+from ...types import CHAR
+from ...types import DATE
+from ...types import FLOAT
+from ...types import INTEGER
+from ...types import NUMERIC
+from ...types import REAL
+from ...types import SMALLINT
+from ...types import TEXT
+from ...types import VARCHAR
+
 
 try:
-    from uuid import UUID as _python_UUID
+    from uuid import UUID as _python_UUID  # noqa
 except ImportError:
     _python_UUID = None
 
-from sqlalchemy.types import (
-    INTEGER,
-    BIGINT,
-    SMALLINT,
-    VARCHAR,
-    CHAR,
-    TEXT,
-    FLOAT,
-    NUMERIC,
-    DATE,
-    BOOLEAN,
-    REAL,
-)
 
 AUTOCOMMIT_REGEXP = re.compile(
     r"\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|GRANT|REVOKE|"
@@ -2022,7 +2026,7 @@ class PGDDLCompiler(compiler.DDLCompiler):
 
 
 class PGTypeCompiler(compiler.GenericTypeCompiler):
-    def visit_TSVECTOR(self, type, **kw):
+    def visit_TSVECTOR(self, type_, **kw):
         return "TSVECTOR"
 
     def visit_INET(self, type_, **kw):
@@ -3087,9 +3091,21 @@ class PGDialect(default.DefaultDialect):
         for conname, condef, conschema in c.fetchall():
             m = re.search(FK_REGEX, condef).groups()
 
-            constrained_columns, referred_schema, referred_table, referred_columns, _, match, _, onupdate, _, ondelete, deferrable, _, initially = (
-                m
-            )
+            (
+                constrained_columns,
+                referred_schema,
+                referred_table,
+                referred_columns,
+                _,
+                match,
+                _,
+                onupdate,
+                _,
+                ondelete,
+                deferrable,
+                _,
+                initially,
+            ) = m
 
             if deferrable is not None:
                 deferrable = True if deferrable == "DEFERRABLE" else False
index 825f13238758ec776522a41a2e6a344e80e9c9f7..9698e36ba6f68ccd71705ad3cecb07f388d3c2f8 100644 (file)
@@ -5,14 +5,15 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from ...sql.elements import ClauseElement, _literal_as_binds
+from . import ext
+from ... import util
+from ...sql import schema
+from ...sql.base import _generative
 from ...sql.dml import Insert as StandardInsert
+from ...sql.elements import ClauseElement
 from ...sql.expression import alias
-from ...sql import schema
 from ...util.langhelpers import public_factory
-from ...sql.base import _generative
-from ... import util
-from . import ext
+
 
 __all__ = ("Insert", "insert")
 
@@ -51,7 +52,7 @@ class Insert(StandardInsert):
         set_=None,
         where=None,
     ):
-        """
+        r"""
         Specifies a DO UPDATE SET action for ON CONFLICT clause.
 
         Either the ``constraint`` or ``index_elements`` argument is
@@ -70,7 +71,7 @@ class Insert(StandardInsert):
          Additional WHERE criterion that can be used to infer a
          conditional target index.
 
-        :param set_:
+        :param set\_:
          Required argument. A dictionary or other mapping object
          with column names as keys and expressions or literals as values,
          specifying the ``SET`` actions to take.
index da0c6250c48d942ce46bc006a665d15ac1caeb0e..7f97d6e32d62d9309879a656a6a723e002ae2a63 100644 (file)
@@ -5,11 +5,11 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from ...sql import expression
+from .array import ARRAY
 from ...sql import elements
+from ...sql import expression
 from ...sql import functions
 from ...sql.schema import ColumnCollectionConstraint
-from .array import ARRAY
 
 
 class aggregate_order_by(expression.ColumnElement):
@@ -83,9 +83,9 @@ class ExcludeConstraint(ColumnCollectionConstraint):
     Defines an EXCLUDE constraint as described in the `postgres
     documentation`__.
 
-    __ http://www.postgresql.org/docs/9.0/\
-static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
-    """
+    __ http://www.postgresql.org/docs/9.0/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
+
+    """  # noqa
 
     __visit_name__ = "exclude_constraint"
 
index e4bac692a3097a0f374b57feeed070795dca185f..b1511acd445f0d1826d39d65513c9c3d325ca9b8 100644 (file)
@@ -7,12 +7,13 @@
 
 import re
 
-from .base import ischema_names
 from .array import ARRAY
+from .base import ischema_names
 from ... import types as sqltypes
+from ... import util
 from ...sql import functions as sqlfunc
 from ...sql import operators
-from ... import util
+
 
 __all__ = ("HSTORE", "hstore")
 
index f9421de37c93f51a287c16573b44e7798f26ee39..1ac040abc0ba033a0ad1a9ad79d6bb85fdf373ce 100644 (file)
@@ -6,11 +6,12 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 from __future__ import absolute_import
 
-from .base import ischema_names, colspecs
+from .base import colspecs
+from .base import ischema_names
 from ... import types as sqltypes
-from ...sql import operators
-from ...sql import elements
 from ... import util
+from ...sql import operators
+
 
 __all__ = ("JSON", "JSONB")
 
@@ -133,8 +134,7 @@ class JSON(sqltypes.JSON):
 
     * Path index operations returning text (the ``#>>`` operator)::
 
-        data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')].astext == \
-'some value'
+        data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')].astext == 'some value'
 
     .. versionchanged:: 1.1  The :meth:`.ColumnElement.cast` operator on
        JSON objects now requires that the :attr:`.JSON.Comparator.astext`
@@ -164,7 +164,7 @@ class JSON(sqltypes.JSON):
 
         :class:`.JSONB`
 
-    """
+    """  # noqa
 
     astext_type = sqltypes.Text()
 
index fef09e0ebb16df36ce5930c5ad89a1d2ae180d1a..1eb24668b52f2f576b311b23d2c8c55d512be495 100644 (file)
@@ -4,13 +4,11 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
-
-"""
+r"""
 .. dialect:: postgresql+pg8000
     :name: pg8000
     :dbapi: pg8000
-    :connectstring: \
-postgresql+pg8000://user:password@host:port/dbname[?key=value&key=value...]
+    :connectstring: postgresql+pg8000://user:password@host:port/dbname[?key=value&key=value...]
     :url: https://pythonhosted.org/pg8000/
 
 
@@ -63,27 +61,28 @@ of the :ref:`psycopg2 <psycopg2_isolation_level>` dialect:
     :ref:`psycopg2_isolation_level`
 
 
-"""
-from ... import util, exc
+"""  # noqa
 import decimal
+import re
+
+from .base import _DECIMAL_TYPES
+from .base import _FLOAT_TYPES
+from .base import _INT_TYPES
+from .base import PGCompiler
+from .base import PGDialect
+from .base import PGExecutionContext
+from .base import PGIdentifierPreparer
+from .base import UUID
+from .json import JSON
+from ... import exc
 from ... import processors
 from ... import types as sqltypes
-from .base import (
-    PGDialect,
-    PGCompiler,
-    PGIdentifierPreparer,
-    PGExecutionContext,
-    _DECIMAL_TYPES,
-    _FLOAT_TYPES,
-    _INT_TYPES,
-    UUID,
-)
-import re
-from sqlalchemy.dialects.postgresql.json import JSON
+from ... import util
 from ...sql.elements import quoted_name
 
+
 try:
-    from uuid import UUID as _python_UUID
+    from uuid import UUID as _python_UUID  # noqa
 except ImportError:
     _python_UUID = None
 
index 2c27c69193b4cc19ed3f6a405576003f5519f33f..30203d20484e92bb66af1b095bb4dc82834afb5b 100644 (file)
@@ -4,7 +4,6 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
-
 r"""
 .. dialect:: postgresql+psycopg2
     :name: psycopg2
@@ -77,12 +76,12 @@ in ``/tmp``, or whatever socket directory was specified when PostgreSQL
 was built.  This value can be overridden by passing a pathname to psycopg2,
 using ``host`` as an additional keyword argument::
 
-    create_engine("postgresql+psycopg2://user:password@/dbname?\
-host=/var/lib/postgresql")
+    create_engine("postgresql+psycopg2://user:password@/dbname?host=/var/lib/postgresql")
 
 .. seealso::
 
-    `PQconnectdbParams <http://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-PQCONNECTDBPARAMS>`_
+    `PQconnectdbParams \
+    <http://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-PQCONNECTDBPARAMS>`_
 
 .. _psycopg2_execution_options:
 
@@ -93,13 +92,13 @@ The following DBAPI-specific options are respected when used with
 :meth:`.Connection.execution_options`, :meth:`.Executable.execution_options`,
 :meth:`.Query.execution_options`, in addition to those not specific to DBAPIs:
 
-* ``isolation_level`` - Set the transaction isolation level for the lifespan of a
-  :class:`.Connection` (can only be set on a connection, not a statement
+* ``isolation_level`` - Set the transaction isolation level for the lifespan
+  of a :class:`.Connection` (can only be set on a connection, not a statement
   or query).   See :ref:`psycopg2_isolation_level`.
 
-* ``stream_results`` - Enable or disable usage of psycopg2 server side cursors -
-  this feature makes use of "named" cursors in combination with special
-  result handling methods so that result rows are not fully buffered.
+* ``stream_results`` - Enable or disable usage of psycopg2 server side
+  cursors - this feature makes use of "named" cursors in combination with
+  special result handling methods so that result rows are not fully buffered.
   If ``None`` or not set, the ``server_side_cursors`` option of the
   :class:`.Engine` is used.
 
@@ -116,7 +115,8 @@ Psycopg2 Batch Mode (Fast Execution)
 ------------------------------------
 
 Modern versions of psycopg2 include a feature known as
-`Fast Execution Helpers <http://initd.org/psycopg/docs/extras.html#fast-execution-helpers>`_,
+`Fast Execution Helpers \
+<http://initd.org/psycopg/docs/extras.html#fast-execution-helpers>`_,
 which have been shown in benchmarking to improve psycopg2's executemany()
 performance with INSERTS by multiple orders of magnitude.   SQLAlchemy
 allows this extension to be used for all ``executemany()`` style calls
@@ -176,10 +176,9 @@ now supported by libpq directly.   This is enabled when ``client_encoding``
 is passed directly to ``psycopg2.connect()``, and from SQLAlchemy is passed
 using the :paramref:`.create_engine.connect_args` parameter::
 
-    # libpq direct parameter setting;
-    # only works for PostgreSQL **9.1 and above**
-    engine = create_engine("postgresql://user:pass@host/dbname",
-                           connect_args={'client_encoding': 'utf8'})
+    engine = create_engine(
+        "postgresql://user:pass@host/dbname",
+        connect_args={'client_encoding': 'utf8'})
 
     # using the query string is equivalent
     engine = create_engine("postgresql://user:pass@host/dbname?client_encoding=utf8")
@@ -294,8 +293,8 @@ The psycopg2 dialect supports these constants for isolation level:
 NOTICE logging
 ---------------
 
-The psycopg2 dialect will log PostgreSQL NOTICE messages via the
-``sqlalchemy.dialects.postgresql`` logger::
+The psycopg2 dialect will log PostgreSQL NOTICE messages
+via the ``sqlalchemy.dialects.postgresql`` logger::
 
     import logging
     logging.getLogger('sqlalchemy.dialects.postgresql').setLevel(logging.INFO)
@@ -341,34 +340,34 @@ string format, on both the parameter side and the result side, will take
 place within SQLAlchemy's own marshalling logic, and not that of ``psycopg2``
 which may be more performant.
 
-"""
+"""  # noqa
 from __future__ import absolute_import
 
-import re
+import decimal
 import logging
+import re
 
-from ... import util, exc
-import decimal
+from .base import _DECIMAL_TYPES
+from .base import _FLOAT_TYPES
+from .base import _INT_TYPES
+from .base import ENUM
+from .base import PGCompiler
+from .base import PGDialect
+from .base import PGExecutionContext
+from .base import PGIdentifierPreparer
+from .base import UUID
+from .hstore import HSTORE
+from .json import JSON
+from .json import JSONB
+from ... import exc
 from ... import processors
-from ...engine import result as _result
-from ...sql import expression
 from ... import types as sqltypes
-from .base import (
-    PGDialect,
-    PGCompiler,
-    PGIdentifierPreparer,
-    PGExecutionContext,
-    ENUM,
-    _DECIMAL_TYPES,
-    _FLOAT_TYPES,
-    _INT_TYPES,
-    UUID,
-)
-from .hstore import HSTORE
-from .json import JSON, JSONB
+from ... import util
+from ...engine import result as _result
+
 
 try:
-    from uuid import UUID as _python_UUID
+    from uuid import UUID as _python_UUID  # noqa
 except ImportError:
     _python_UUID = None
 
@@ -448,7 +447,6 @@ class _PGJSONB(JSONB):
 class _PGUUID(UUID):
     def bind_processor(self, dialect):
         if not self.as_uuid and dialect.use_native_uuid:
-            nonetype = type(None)
 
             def process(value):
                 if value is not None:
index 7343bc97357842b9ccf4b98cc903175f52bf8b58..c31527a44e57df9d283a4c934180c796b7138de1 100644 (file)
@@ -4,13 +4,11 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
+r"""
 .. dialect:: postgresql+psycopg2cffi
     :name: psycopg2cffi
     :dbapi: psycopg2cffi
-    :connectstring: \
-postgresql+psycopg2cffi://user:password@host:port/dbname\
-[?key=value&key=value...]
+    :connectstring: postgresql+psycopg2cffi://user:password@host:port/dbname[?key=value&key=value...]
     :url: http://pypi.python.org/pypi/psycopg2cffi/
 
 ``psycopg2cffi`` is an adaptation of ``psycopg2``, using CFFI for the C
@@ -23,7 +21,7 @@ is as per ``psycopg2``.
 
     :mod:`sqlalchemy.dialects.postgresql.psycopg2`
 
-"""
+"""  # noqa
 from .psycopg2 import PGDialect_psycopg2
 
 
index c7edb8fc3dd1c25e9373183f9084514bba357f91..13a3118b5a94f01b2371a37779fe20138a159f32 100644 (file)
@@ -4,33 +4,33 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
-
 """
 .. dialect:: postgresql+pygresql
     :name: pygresql
     :dbapi: pgdb
-    :connectstring: postgresql+pygresql://user:password@host:port/dbname\
-[?key=value&key=value...]
+    :connectstring: postgresql+pygresql://user:password@host:port/dbname[?key=value&key=value...]
     :url: http://www.pygresql.org/
-"""
+"""  # noqa
 
 import decimal
 import re
 
-from ... import exc, processors, util
-from ...types import Numeric, JSON as Json
-from ...sql.elements import Null
-from .base import (
-    PGDialect,
-    PGCompiler,
-    PGIdentifierPreparer,
-    _DECIMAL_TYPES,
-    _FLOAT_TYPES,
-    _INT_TYPES,
-    UUID,
-)
+from .base import _DECIMAL_TYPES
+from .base import _FLOAT_TYPES
+from .base import _INT_TYPES
+from .base import PGCompiler
+from .base import PGDialect
+from .base import PGIdentifierPreparer
+from .base import UUID
 from .hstore import HSTORE
-from .json import JSON, JSONB
+from .json import JSON
+from .json import JSONB
+from ... import exc
+from ... import processors
+from ... import util
+from ...sql.elements import Null
+from ...types import JSON as Json
+from ...types import Numeric
 
 
 class _PGNumeric(Numeric):
index 93bf653a45205195c143c6ab808cfeb7a22a4b35..398ac290d5913c48c61e7e5ffab10746f8ffe5e5 100644 (file)
@@ -4,21 +4,21 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
-
 """
 .. dialect:: postgresql+pypostgresql
     :name: py-postgresql
     :dbapi: pypostgresql
-    :connectstring: postgresql+pypostgresql://user:password@host:port/dbname\
-[?key=value&key=value...]
+    :connectstring: postgresql+pypostgresql://user:password@host:port/dbname[?key=value&key=value...]
     :url: http://python.projects.pgfoundry.org/
 
 
-"""
-from ... import util
-from ... import types as sqltypes
-from .base import PGDialect, PGExecutionContext
+"""  # noqa
+
+from .base import PGDialect
+from .base import PGExecutionContext
 from ... import processors
+from ... import types as sqltypes
+from ... import util
 
 
 class PGNumeric(sqltypes.Numeric):
index 62d1275a60f6b635b888df6acf4bea64a3b7c246..9558f7c486900bec2a4e613527e319a4ee8dd54f 100644 (file)
@@ -7,6 +7,7 @@
 from .base import ischema_names
 from ... import types as sqltypes
 
+
 __all__ = ("INT4RANGE", "INT8RANGE", "NUMRANGE")
 
 
index 4d984443ae7aac9ee2b83460cedaa09fdbb5bd3b..ab77e5bc8c04bfbeb15d754f8d55ce2e3c306ddc 100644 (file)
@@ -14,8 +14,9 @@
 
 
 """
+from .base import PGDialect
+from .base import PGExecutionContext
 from ...connectors.zxJDBC import ZxJDBCConnector
-from .base import PGDialect, PGExecutionContext
 
 
 class PGExecutionContext_zxjdbc(PGExecutionContext):
index 41f0175975915f830d8a220a58ae03246c706ed2..fa70717d12a8709e82150dff69415776225b2e06 100644 (file)
@@ -5,26 +5,26 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import base, pysqlite, pysqlcipher  # noqa
+from . import base  # noqa
+from . import pysqlcipher  # noqa
+from . import pysqlite  # noqa
+from .base import BLOB
+from .base import BOOLEAN
+from .base import CHAR
+from .base import DATE
+from .base import DATETIME
+from .base import DECIMAL
+from .base import FLOAT
+from .base import INTEGER
+from .base import JSON
+from .base import NUMERIC
+from .base import REAL
+from .base import SMALLINT
+from .base import TEXT
+from .base import TIME
+from .base import TIMESTAMP
+from .base import VARCHAR
 
-from sqlalchemy.dialects.sqlite.base import (
-    BLOB,
-    BOOLEAN,
-    CHAR,
-    DATE,
-    DATETIME,
-    DECIMAL,
-    FLOAT,
-    INTEGER,
-    JSON,
-    REAL,
-    NUMERIC,
-    SMALLINT,
-    TEXT,
-    TIME,
-    TIMESTAMP,
-    VARCHAR,
-)
 
 # default dialect
 base.dialect = dialect = pysqlite.dialect
index cb9389af18e3357dd0b1aecbb2e46d9614cacf81..1eea2b6c65dbf643a4dab07bf21430c08dff7135 100644 (file)
@@ -36,7 +36,8 @@ so that the column continues to have textual affinity.
 
 .. seealso::
 
-    `Type Affinity <http://www.sqlite.org/datatype3.html#affinity>`_ - in the SQLite documentation
+    `Type Affinity <http://www.sqlite.org/datatype3.html#affinity>`_ -
+    in the SQLite documentation
 
 .. _sqlite_autoincrement:
 
@@ -71,18 +72,16 @@ construct::
 Allowing autoincrement behavior SQLAlchemy types other than Integer/INTEGER
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-SQLite's typing model is based on naming conventions.  Among
-other things, this means that any type name which contains the
-substring ``"INT"`` will be determined to be of "integer affinity".  A
-type named ``"BIGINT"``, ``"SPECIAL_INT"`` or even ``"XYZINTQPR"``, will be considered by
-SQLite to be of "integer" affinity.  However, **the SQLite
-autoincrement feature, whether implicitly or explicitly enabled,
-requires that the name of the column's type
-is exactly the string "INTEGER"**.  Therefore, if an
-application uses a type like :class:`.BigInteger` for a primary key, on
-SQLite this type will need to be rendered as the name ``"INTEGER"`` when
-emitting the initial ``CREATE TABLE`` statement in order for the autoincrement
-behavior to be available.
+SQLite's typing model is based on naming conventions.  Among other things, this
+means that any type name which contains the substring ``"INT"`` will be
+determined to be of "integer affinity".  A type named ``"BIGINT"``,
+``"SPECIAL_INT"`` or even ``"XYZINTQPR"``, will be considered by SQLite to be
+of "integer" affinity.  However, **the SQLite autoincrement feature, whether
+implicitly or explicitly enabled, requires that the name of the column's type
+is exactly the string "INTEGER"**.  Therefore, if an application uses a type
+like :class:`.BigInteger` for a primary key, on SQLite this type will need to
+be rendered as the name ``"INTEGER"`` when emitting the initial ``CREATE
+TABLE`` statement in order for the autoincrement behavior to be available.
 
 One approach to achieve this is to use :class:`.Integer` on SQLite
 only using :meth:`.TypeEngine.with_variant`::
@@ -92,8 +91,8 @@ only using :meth:`.TypeEngine.with_variant`::
         Column("id", BigInteger().with_variant(Integer, "sqlite"), primary_key=True)
     )
 
-Another is to use a subclass of :class:`.BigInteger` that overrides its DDL name
-to be ``INTEGER`` when compiled against SQLite::
+Another is to use a subclass of :class:`.BigInteger` that overrides its DDL
+name to be ``INTEGER`` when compiled against SQLite::
 
     from sqlalchemy import BigInteger
     from sqlalchemy.ext.compiler import compiles
@@ -173,7 +172,8 @@ Transaction Isolation Level
 ----------------------------
 
 SQLite supports "transaction isolation" in a non-standard way, along two
-axes.  One is that of the `PRAGMA read_uncommitted <http://www.sqlite.org/pragma.html#pragma_read_uncommitted>`_
+axes.  One is that of the
+`PRAGMA read_uncommitted <http://www.sqlite.org/pragma.html#pragma_read_uncommitted>`_
 instruction.   This setting can essentially switch SQLite between its
 default mode of ``SERIALIZABLE`` isolation, and a "dirty read" isolation
 mode normally referred to as ``READ UNCOMMITTED``.
@@ -546,12 +546,12 @@ names are still addressable*::
     1
 
 Therefore, the workaround applied by SQLAlchemy only impacts
-:meth:`.ResultProxy.keys` and :meth:`.RowProxy.keys()` in the public API.
-In the very specific case where
-an application is forced to use column names that contain dots, and the
-functionality of :meth:`.ResultProxy.keys` and :meth:`.RowProxy.keys()`
-is required to return these dotted names unmodified, the ``sqlite_raw_colnames``
-execution option may be provided, either on a per-:class:`.Connection` basis::
+:meth:`.ResultProxy.keys` and :meth:`.RowProxy.keys()` in the public API. In
+the very specific case where an application is forced to use column names that
+contain dots, and the functionality of :meth:`.ResultProxy.keys` and
+:meth:`.RowProxy.keys()` is required to return these dotted names unmodified,
+the ``sqlite_raw_colnames`` execution option may be provided, either on a
+per-:class:`.Connection` basis::
 
     result = conn.execution_options(sqlite_raw_colnames=True).execute('''
         select x.a, x.b from x where a=1
@@ -567,33 +567,35 @@ or on a per-:class:`.Engine` basis::
 When using the per-:class:`.Engine` execution option, note that
 **Core and ORM queries that use UNION may not function properly**.
 
-"""
+"""  # noqa
 
 import datetime
 import re
 
+from .json import JSON
+from .json import JSONIndexType
+from .json import JSONPathType
+from ... import exc
 from ... import processors
-from ... import sql, exc
-from ... import types as sqltypes, schema as sa_schema
+from ... import schema as sa_schema
+from ... import sql
+from ... import types as sqltypes
 from ... import util
-from ...engine import default, reflection
+from ...engine import default
+from ...engine import reflection
 from ...sql import compiler
-
-from ...types import (
-    BLOB,
-    BOOLEAN,
-    CHAR,
-    DECIMAL,
-    FLOAT,
-    INTEGER,
-    REAL,
-    NUMERIC,
-    SMALLINT,
-    TEXT,
-    TIMESTAMP,
-    VARCHAR,
-)
-from .json import JSON, JSONIndexType, JSONPathType
+from ...types import BLOB  # noqa
+from ...types import BOOLEAN  # noqa
+from ...types import CHAR  # noqa
+from ...types import DECIMAL  # noqa
+from ...types import FLOAT  # noqa
+from ...types import INTEGER  # noqa
+from ...types import NUMERIC  # noqa
+from ...types import REAL  # noqa
+from ...types import SMALLINT  # noqa
+from ...types import TEXT  # noqa
+from ...types import TIMESTAMP  # noqa
+from ...types import VARCHAR  # noqa
 
 
 class _DateTimeMixin(object):
@@ -680,7 +682,7 @@ class DATETIME(_DateTimeMixin, sqltypes.DateTime):
      is called with positional arguments via
      ``*map(int, match_obj.groups(0))``.
 
-    """
+    """  # noqa
 
     _storage_format = (
         "%(year)04d-%(month)02d-%(day)02d "
@@ -707,13 +709,13 @@ class DATETIME(_DateTimeMixin, sqltypes.DateTime):
     def bind_processor(self, dialect):
         datetime_datetime = datetime.datetime
         datetime_date = datetime.date
-        format = self._storage_format
+        format_ = self._storage_format
 
         def process(value):
             if value is None:
                 return None
             elif isinstance(value, datetime_datetime):
-                return format % {
+                return format_ % {
                     "year": value.year,
                     "month": value.month,
                     "day": value.day,
@@ -723,7 +725,7 @@ class DATETIME(_DateTimeMixin, sqltypes.DateTime):
                     "microsecond": value.microsecond,
                 }
             elif isinstance(value, datetime_date):
-                return format % {
+                return format_ % {
                     "year": value.year,
                     "month": value.month,
                     "day": value.day,
@@ -786,13 +788,13 @@ class DATE(_DateTimeMixin, sqltypes.Date):
 
     def bind_processor(self, dialect):
         datetime_date = datetime.date
-        format = self._storage_format
+        format_ = self._storage_format
 
         def process(value):
             if value is None:
                 return None
             elif isinstance(value, datetime_date):
-                return format % {
+                return format_ % {
                     "year": value.year,
                     "month": value.month,
                     "day": value.day,
@@ -864,13 +866,13 @@ class TIME(_DateTimeMixin, sqltypes.Time):
 
     def bind_processor(self, dialect):
         datetime_time = datetime.time
-        format = self._storage_format
+        format_ = self._storage_format
 
         def process(value):
             if value is None:
                 return None
             elif isinstance(value, datetime_time):
-                return format % {
+                return format_ % {
                     "hour": value.hour,
                     "minute": value.minute,
                     "second": value.second,
index fca425127ce01926a2d07f5bb24ec880611facd4..66abef38ff73046a0efbac6a3fbfff37f601e59c 100644 (file)
@@ -25,7 +25,8 @@
 Driver
 ------
 
-The driver here is the `pysqlcipher <https://pypi.python.org/pypi/pysqlcipher>`_
+The driver here is the
+`pysqlcipher <https://pypi.python.org/pypi/pysqlcipher>`_
 driver, which makes use of the SQLCipher engine.  This system essentially
 introduces new PRAGMA commands to SQLite which allows the setting of a
 passphrase and other encryption parameters, allowing the database
@@ -74,11 +75,13 @@ to prevent unencrypted connections from being held open for long periods of
 time, at the expense of slower startup time for new connections.
 
 
-"""
+"""  # noqa
+
 from __future__ import absolute_import
+
 from .pysqlite import SQLiteDialect_pysqlite
-from ...engine import url as _url
 from ... import pool
+from ...engine import url as _url
 
 
 class SQLiteDialect_pysqlcipher(SQLiteDialect_pysqlite):
index e78d76ae6c6bb289175a96d742c524bf56bafac4..67bfa313fb9f96d540fa3491a5a95efe4a64b8bb 100644 (file)
@@ -246,7 +246,8 @@ integration.   Then, at the point at which SQLAlchemy knows that transaction
 scope is to begin, we emit ``"BEGIN"`` ourselves.
 
 When we take control of ``"BEGIN"``, we can also control directly SQLite's
-locking modes, introduced at `BEGIN TRANSACTION <http://sqlite.org/lang_transaction.html>`_,
+locking modes, introduced at
+`BEGIN TRANSACTION <http://sqlite.org/lang_transaction.html>`_,
 by adding the desired locking mode to our ``"BEGIN"``::
 
     @event.listens_for(engine, "begin")
@@ -255,22 +256,28 @@ by adding the desired locking mode to our ``"BEGIN"``::
 
 .. seealso::
 
-    `BEGIN TRANSACTION <http://sqlite.org/lang_transaction.html>`_ - on the SQLite site
+    `BEGIN TRANSACTION <http://sqlite.org/lang_transaction.html>`_ -
+    on the SQLite site
 
-    `sqlite3 SELECT does not BEGIN a transaction <http://bugs.python.org/issue9924>`_ - on the Python bug tracker
+    `sqlite3 SELECT does not BEGIN a transaction <http://bugs.python.org/issue9924>`_ -
+    on the Python bug tracker
 
-    `sqlite3 module breaks transactions and potentially corrupts data <http://bugs.python.org/issue10740>`_ - on the Python bug tracker
+    `sqlite3 module breaks transactions and potentially corrupts data <http://bugs.python.org/issue10740>`_ -
+    on the Python bug tracker
 
 
-"""
-
-from sqlalchemy.dialects.sqlite.base import SQLiteDialect, DATETIME, DATE
-from sqlalchemy import exc, pool
-from sqlalchemy import types as sqltypes
-from sqlalchemy import util
+"""  # noqa
 
 import os
 
+from .base import DATE
+from .base import DATETIME
+from .base import SQLiteDialect
+from ... import exc
+from ... import pool
+from ... import types as sqltypes
+from ... import util
+
 
 class _SQLite_pysqliteTimeStamp(DATETIME):
     def bind_processor(self, dialect):
index 2f55d3bf6fb1586cd93cee892e34528b27e58777..9b247fa708ee6782bba3ae2fc9f93233994fa582 100644 (file)
@@ -5,34 +5,34 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import base, pysybase, pyodbc  # noqa
+from . import base  # noqa
+from . import pyodbc  # noqa
+from . import pysybase  # noqa
+from .base import BIGINT
+from .base import BINARY
+from .base import BIT
+from .base import CHAR
+from .base import DATE
+from .base import DATETIME
+from .base import FLOAT
+from .base import IMAGE
+from .base import INT
+from .base import INTEGER
+from .base import MONEY
+from .base import NCHAR
+from .base import NUMERIC
+from .base import NVARCHAR
+from .base import SMALLINT
+from .base import SMALLMONEY
+from .base import TEXT
+from .base import TIME
+from .base import TINYINT
+from .base import UNICHAR
+from .base import UNITEXT
+from .base import UNIVARCHAR
+from .base import VARBINARY
+from .base import VARCHAR
 
-from .base import (
-    CHAR,
-    VARCHAR,
-    TIME,
-    NCHAR,
-    NVARCHAR,
-    TEXT,
-    DATE,
-    DATETIME,
-    FLOAT,
-    NUMERIC,
-    BIGINT,
-    INT,
-    INTEGER,
-    SMALLINT,
-    BINARY,
-    VARBINARY,
-    UNITEXT,
-    UNICHAR,
-    UNIVARCHAR,
-    IMAGE,
-    BIT,
-    MONEY,
-    SMALLMONEY,
-    TINYINT,
-)
 
 # default dialect
 base.dialect = dialect = pyodbc.dialect
index 1214a927948496ed54a4ccff5bfbf8838462a5ea..8fdc011e33bb61874c69bbc091171ee5499f19f4 100644 (file)
     caveats not currently handled.
 
 """
-import operator
+
 import re
 
-from sqlalchemy.sql import compiler, expression, text, bindparam
-from sqlalchemy.engine import default, base, reflection
-from sqlalchemy import types as sqltypes
-from sqlalchemy.sql import operators as sql_operators
+from sqlalchemy import exc
 from sqlalchemy import schema as sa_schema
-from sqlalchemy import util, sql, exc
-
-from sqlalchemy.types import (
-    CHAR,
-    VARCHAR,
-    TIME,
-    NCHAR,
-    NVARCHAR,
-    TEXT,
-    DATE,
-    DATETIME,
-    FLOAT,
-    NUMERIC,
-    BIGINT,
-    INT,
-    INTEGER,
-    SMALLINT,
-    BINARY,
-    VARBINARY,
-    DECIMAL,
-    TIMESTAMP,
-    Unicode,
-    UnicodeText,
-    REAL,
-)
+from sqlalchemy import types as sqltypes
+from sqlalchemy import util
+from sqlalchemy.engine import default
+from sqlalchemy.engine import reflection
+from sqlalchemy.sql import compiler
+from sqlalchemy.sql import text
+from sqlalchemy.types import BIGINT
+from sqlalchemy.types import BINARY
+from sqlalchemy.types import CHAR
+from sqlalchemy.types import DATE
+from sqlalchemy.types import DATETIME
+from sqlalchemy.types import DECIMAL
+from sqlalchemy.types import FLOAT
+from sqlalchemy.types import INT  # noqa
+from sqlalchemy.types import INTEGER
+from sqlalchemy.types import NCHAR
+from sqlalchemy.types import NUMERIC
+from sqlalchemy.types import NVARCHAR
+from sqlalchemy.types import REAL
+from sqlalchemy.types import SMALLINT
+from sqlalchemy.types import TEXT
+from sqlalchemy.types import TIME
+from sqlalchemy.types import TIMESTAMP
+from sqlalchemy.types import Unicode
+from sqlalchemy.types import VARBINARY
+from sqlalchemy.types import VARCHAR
+
 
 RESERVED_WORDS = set(
     [
@@ -696,9 +695,9 @@ class SybaseDialect(default.DefaultDialect):
         )
 
         if util.py2k:
-            if isinstance(schema, unicode):
+            if isinstance(schema, unicode):  # noqa
                 schema = schema.encode("ascii")
-            if isinstance(table_name, unicode):
+            if isinstance(table_name, unicode):  # noqa
                 table_name = table_name.encode("ascii")
         result = connection.execute(
             TABLEID_SQL, schema_name=schema, table_name=table_name
@@ -740,7 +739,7 @@ class SybaseDialect(default.DefaultDialect):
             type_,
             nullable,
             autoincrement,
-            default,
+            default_,
             precision,
             scale,
             length,
@@ -750,7 +749,7 @@ class SybaseDialect(default.DefaultDialect):
                 type_,
                 bool(nullable),
                 bool(autoincrement),
-                default,
+                default_,
                 precision,
                 scale,
                 length,
@@ -1037,7 +1036,7 @@ class SybaseDialect(default.DefaultDialect):
         )
 
         if util.py2k:
-            if isinstance(schema, unicode):
+            if isinstance(schema, unicode):  # noqa
                 schema = schema.encode("ascii")
 
         tables = connection.execute(TABLE_SQL, schema_name=schema)
@@ -1059,7 +1058,7 @@ class SybaseDialect(default.DefaultDialect):
         )
 
         if util.py2k:
-            if isinstance(view_name, unicode):
+            if isinstance(view_name, unicode):  # noqa
                 view_name = view_name.encode("ascii")
 
         view = connection.execute(VIEW_DEF_SQL, view_name=view_name)
@@ -1081,7 +1080,7 @@ class SybaseDialect(default.DefaultDialect):
         )
 
         if util.py2k:
-            if isinstance(schema, unicode):
+            if isinstance(schema, unicode):  # noqa
                 schema = schema.encode("ascii")
         views = connection.execute(VIEW_SQL, schema_name=schema)
 
index eeceb359b76b17a6822a7eb84140aa274b18c145..482db9745fb92d9043b360e08fb0a3107b7eddbe 100644 (file)
@@ -18,9 +18,9 @@
 
 
 """
+from sqlalchemy.connectors.mxodbc import MxODBCConnector
 from sqlalchemy.dialects.sybase.base import SybaseDialect
 from sqlalchemy.dialects.sybase.base import SybaseExecutionContext
-from sqlalchemy.connectors.mxodbc import MxODBCConnector
 
 
 class SybaseExecutionContext_mxodbc(SybaseExecutionContext):
index a4759428c867ac2868a3269ea179442947c80dd8..ba299befdb11f670a70184e3dc53ba98ace5eef5 100644 (file)
@@ -9,8 +9,7 @@
 .. dialect:: sybase+pyodbc
     :name: PyODBC
     :dbapi: pyodbc
-    :connectstring: sybase+pyodbc://<username>:<password>@<dsnname>\
-[/<database>]
+    :connectstring: sybase+pyodbc://<username>:<password>@<dsnname>[/<database>]
     :url: http://pypi.python.org/pypi/pyodbc/
 
 
@@ -32,16 +31,16 @@ Currently *not* supported are::
     UNITEXT
     UNIVARCHAR
 
-"""
+"""  # noqa
 
-from sqlalchemy.dialects.sybase.base import (
-    SybaseDialect,
-    SybaseExecutionContext,
-)
-from sqlalchemy.connectors.pyodbc import PyODBCConnector
-from sqlalchemy import types as sqltypes, processors
 import decimal
 
+from sqlalchemy import processors
+from sqlalchemy import types as sqltypes
+from sqlalchemy.connectors.pyodbc import PyODBCConnector
+from sqlalchemy.dialects.sybase.base import SybaseDialect
+from sqlalchemy.dialects.sybase.base import SybaseExecutionContext
+
 
 class _SybNumeric_pyodbc(sqltypes.Numeric):
     """Turns Decimals with adjusted() < -6 into floats.
index 09d2cf380f7e769097c92ff39e9f1f3f43e440be..9fedc9f267d40a24b500415e99a752b722bbf52e 100644 (file)
@@ -9,8 +9,7 @@
 .. dialect:: sybase+pysybase
     :name: Python-Sybase
     :dbapi: Sybase
-    :connectstring: sybase+pysybase://<username>:<password>@<dsn>/\
-[database name]
+    :connectstring: sybase+pysybase://<username>:<password>@<dsn>/[database name]
     :url: http://python-sybase.sourceforge.net/
 
 Unicode Support
@@ -19,14 +18,13 @@ Unicode Support
 The python-sybase driver does not appear to support non-ASCII strings of any
 kind at this time.
 
-"""
+"""  # noqa
 
-from sqlalchemy import types as sqltypes, processors
-from sqlalchemy.dialects.sybase.base import (
-    SybaseDialect,
-    SybaseExecutionContext,
-    SybaseSQLCompiler,
-)
+from sqlalchemy import processors
+from sqlalchemy import types as sqltypes
+from sqlalchemy.dialects.sybase.base import SybaseDialect
+from sqlalchemy.dialects.sybase.base import SybaseExecutionContext
+from sqlalchemy.dialects.sybase.base import SybaseSQLCompiler
 
 
 class _SybNumeric(sqltypes.Numeric):
index 590359c38049fa2f888ad081775d9c163c52f4dc..fadc10ad797c7aa5f1d82db41f849de155631e0c 100644 (file)
@@ -51,43 +51,33 @@ url.py
     within a URL.
 """
 
-from .interfaces import (
-    Connectable,
-    CreateEnginePlugin,
-    Dialect,
-    ExecutionContext,
-    ExceptionContext,
-    # backwards compat
-    Compiled,
-    TypeCompiler,
-)
-
-from .base import (
-    Connection,
-    Engine,
-    NestedTransaction,
-    RootTransaction,
-    Transaction,
-    TwoPhaseTransaction,
-)
-
-from .result import (
-    BaseRowProxy,
-    BufferedColumnResultProxy,
-    BufferedColumnRow,
-    BufferedRowResultProxy,
-    FullyBufferedResultProxy,
-    ResultProxy,
-    RowProxy,
-)
-
-from .util import connection_memoize
-
-
-from . import util, strategies
+from . import strategies
+from . import util  # noqa
+from .base import Connection  # noqa
+from .base import Engine  # noqa
+from .base import NestedTransaction  # noqa
+from .base import RootTransaction  # noqa
+from .base import Transaction  # noqa
+from .base import TwoPhaseTransaction  # noqa
+from .interfaces import Compiled  # noqa
+from .interfaces import Connectable  # noqa
+from .interfaces import CreateEnginePlugin  # noqa
+from .interfaces import Dialect  # noqa
+from .interfaces import ExceptionContext  # noqa
+from .interfaces import ExecutionContext  # noqa
+from .interfaces import TypeCompiler  # noqa
+from .result import BaseRowProxy  # noqa
+from .result import BufferedColumnResultProxy  # noqa
+from .result import BufferedColumnRow  # noqa
+from .result import BufferedRowResultProxy  # noqa
+from .result import FullyBufferedResultProxy  # noqa
+from .result import ResultProxy  # noqa
+from .result import RowProxy  # noqa
+from .util import connection_memoize  # noqa
+from ..sql import ddl  # noqa
+
 
 # backwards compat
-from ..sql import ddl
 
 default_strategy = "plain"
 
@@ -298,8 +288,8 @@ def create_engine(*args, **kwargs):
         Behavior here varies per backend, and
         individual dialects should be consulted directly.
 
-        Note that the isolation level can also be set on a per-:class:`.Connection`
-        basis as well, using the
+        Note that the isolation level can also be set on a
+        per-:class:`.Connection` basis as well, using the
         :paramref:`.Connection.execution_options.isolation_level`
         feature.
 
@@ -455,7 +445,7 @@ def create_engine(*args, **kwargs):
         ``(sql, *multiparams, **params)``, to which the ``mock`` strategy will
         dispatch all statement execution. Used only by ``strategy='mock'``.
 
-    """
+    """  # noqa
 
     strategy = kwargs.pop("strategy", default_strategy)
     strategy = strategies.strategies[strategy]
index 75d03b74483d3f23d26ed7de0dba36b4dd7f0db3..c0979ecac05e83dc58f7500f549c425ee7d980ca 100644 (file)
@@ -6,18 +6,23 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 from __future__ import with_statement
 
-"""Defines :class:`.Connection` and :class:`.Engine`.
+import contextlib
+import sys
 
-"""
+from .interfaces import Connectable
+from .interfaces import ExceptionContext
+from .util import _distill_params
+from .. import exc
+from .. import interfaces
+from .. import log
+from .. import util
+from ..sql import schema
+from ..sql import util as sql_util
 
 
-import sys
-from .. import exc, util, log, interfaces
-from ..sql import util as sql_util
-from ..sql import schema
-from .interfaces import Connectable, ExceptionContext
-from .util import _distill_params
-import contextlib
+"""Defines :class:`.Connection` and :class:`.Engine`.
+
+"""
 
 
 class Connection(Connectable):
@@ -172,7 +177,7 @@ class Connection(Connectable):
     def __enter__(self):
         return self
 
-    def __exit__(self, type, value, traceback):
+    def __exit__(self, type_, value, traceback):
         self.close()
 
     def execution_options(self, **opt):
@@ -321,7 +326,7 @@ class Connection(Connectable):
 
             :ref:`schema_translating`
 
-        """
+        """  # noqa
         c = self._clone()
         c._execution_options = c._execution_options.union(opt)
         if self._has_events or self.engine._has_events:
@@ -892,15 +897,15 @@ class Connection(Connectable):
         self.__can_reconnect = False
         self.__transaction = None
 
-    def scalar(self, object, *multiparams, **params):
+    def scalar(self, object_, *multiparams, **params):
         """Executes and returns the first column of the first row.
 
         The underlying result/cursor is closed after execution.
         """
 
-        return self.execute(object, *multiparams, **params).scalar()
+        return self.execute(object_, *multiparams, **params).scalar()
 
-    def execute(self, object, *multiparams, **params):
+    def execute(self, object_, *multiparams, **params):
         r"""Executes a SQL statement construct and returns a
         :class:`.ResultProxy`.
 
@@ -959,12 +964,12 @@ class Connection(Connectable):
          DBAPI-agnostic way, use the :func:`~.expression.text` construct.
 
         """
-        if isinstance(object, util.string_types[0]):
-            return self._execute_text(object, multiparams, params)
+        if isinstance(object_, util.string_types[0]):
+            return self._execute_text(object_, multiparams, params)
         try:
-            meth = object._execute_on_connection
+            meth = object_._execute_on_connection
         except AttributeError:
-            raise exc.ObjectNotExecutableError(object)
+            raise exc.ObjectNotExecutableError(object_)
         else:
             return meth(self, multiparams, params)
 
@@ -1698,8 +1703,8 @@ class Transaction(object):
     def __enter__(self):
         return self
 
-    def __exit__(self, type, value, traceback):
-        if type is None and self.is_active:
+    def __exit__(self, type_, value, traceback):
+        if type_ is None and self.is_active:
             try:
                 self.commit()
             except:
@@ -2005,8 +2010,8 @@ class Engine(Connectable, log.Identified):
         def __enter__(self):
             return self.conn
 
-        def __exit__(self, type, value, traceback):
-            if type is not None:
+        def __exit__(self, type_, value, traceback):
+            if type_ is not None:
                 self.transaction.rollback()
             else:
                 self.transaction.commit()
index d7c2518fe078d97f812afc7e73302154d6360d29..cceae74e8e08667f6b898f8c20e2ea22dd063d69 100644 (file)
@@ -13,15 +13,24 @@ as the base class for their own corresponding classes.
 
 """
 
-import re
-import random
-from . import reflection, interfaces, result
-from ..sql import compiler, expression, schema
-from .. import types as sqltypes
-from .. import exc, util, pool, processors
 import codecs
+import random
+import re
 import weakref
+
+from . import interfaces
+from . import reflection
+from . import result
 from .. import event
+from .. import exc
+from .. import pool
+from .. import processors
+from .. import types as sqltypes
+from .. import util
+from ..sql import compiler
+from ..sql import expression
+from ..sql import schema
+
 
 AUTOCOMMIT_REGEXP = re.compile(
     r"\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER)", re.I | re.UNICODE
@@ -239,13 +248,13 @@ class DefaultDialect(interfaces.Dialect):
         self.label_length = label_length
 
         if self.description_encoding == "use_encoding":
-            self._description_decoder = processors.to_unicode_processor_factory(
-                encoding
-            )
+            self._description_decoder = (
+                processors.to_unicode_processor_factory
+            )(encoding)
         elif self.description_encoding is not None:
-            self._description_decoder = processors.to_unicode_processor_factory(
-                self.description_encoding
-            )
+            self._description_decoder = (
+                processors.to_unicode_processor_factory
+            )(self.description_encoding)
         self._encoder = codecs.getencoder(self.encoding)
         self._decoder = processors.to_unicode_processor_factory(self.encoding)
 
index e10e6e88440c142c3749a37f6b149c971f05c846..f738b5cafcf8cac0906e17c4f3d4a1bebe267527 100644 (file)
@@ -8,9 +8,8 @@
 """Define core interfaces used by the engine system."""
 
 from .. import util
-
-# backwards compat
-from ..sql.compiler import Compiled, TypeCompiler
+from ..sql.compiler import Compiled  # noqa
+from ..sql.compiler import TypeCompiler  # noqa
 
 
 class Dialect(object):
@@ -1157,11 +1156,11 @@ class Connectable(object):
 
         raise NotImplementedError()
 
-    def execute(self, object, *multiparams, **params):
+    def execute(self, object_, *multiparams, **params):
         """Executes the given construct and returns a :class:`.ResultProxy`."""
         raise NotImplementedError()
 
-    def scalar(self, object, *multiparams, **params):
+    def scalar(self, object_, *multiparams, **params):
         """Executes and returns the first column of the first row.
 
         The underlying cursor is closed after execution.
index 9b5fa245951f006cb2aedd31349e0e4ed73232ea..c822ff82033d2c8609a9c4d81172cb38e53c94d5 100644 (file)
@@ -25,14 +25,15 @@ methods such as get_table_names, get_columns, etc.
    'name' attribute..
 """
 
-from .. import exc, sql
-from ..sql import schema as sa_schema
+from .base import Connectable
+from .. import exc
+from .. import inspection
+from .. import sql
 from .. import util
+from ..sql import schema as sa_schema
 from ..sql.type_api import TypeEngine
 from ..util import deprecated
 from ..util import topological
-from .. import inspection
-from .base import Connectable
 
 
 @util.decorator
index 5ad0d2909826cb0a88db9e96655c3cea816de8aa..d672ffefe4b719fce36de77da380281d15ac24b6 100644 (file)
@@ -9,11 +9,16 @@
 and :class:`.RowProxy."""
 
 
-from .. import exc, util
-from ..sql import expression, sqltypes, util as sql_util
 import collections
 import operator
 
+from .. import exc
+from .. import util
+from ..sql import expression
+from ..sql import sqltypes
+from ..sql import util as sql_util
+
+
 # This reconstructor is necessary so that pickles with the C extension or
 # without use the same Binary format.
 try:
@@ -443,7 +448,14 @@ class ResultMetaData(object):
                     obj,
                     untranslated,
                 )
-                for idx, colname, mapped_type, coltype, obj, untranslated in raw_iterator
+                for (
+                    idx,
+                    colname,
+                    mapped_type,
+                    coltype,
+                    obj,
+                    untranslated,
+                ) in raw_iterator
             ]
 
     def _colnames_from_description(self, context, cursor_description):
@@ -575,10 +587,10 @@ class ResultMetaData(object):
         return d
 
     def _key_fallback(self, key, raiseerr=True):
-        map = self._keymap
+        map_ = self._keymap
         result = None
         if isinstance(key, util.string_types):
-            result = map.get(key if self.case_sensitive else key.lower())
+            result = map_.get(key if self.case_sensitive else key.lower())
         # fallback for targeting a ColumnElement to a textual expression
         # this is a rare use case which only occurs when matching text()
         # or colummn('name') constructs to ColumnElements, or after a
@@ -587,18 +599,18 @@ class ResultMetaData(object):
             if (
                 key._label
                 and (key._label if self.case_sensitive else key._label.lower())
-                in map
+                in map_
             ):
-                result = map[
+                result = map_[
                     key._label if self.case_sensitive else key._label.lower()
                 ]
             elif (
                 hasattr(key, "name")
                 and (key.name if self.case_sensitive else key.name.lower())
-                in map
+                in map_
             ):
                 # match is only on name.
-                result = map[
+                result = map_[
                     key.name if self.case_sensitive else key.name.lower()
                 ]
             # search extra hard to make sure this
@@ -620,7 +632,7 @@ class ResultMetaData(object):
             else:
                 return None
         else:
-            map[key] = result
+            map_[key] = result
         return result
 
     def _has_key(self, key):
index 4aecb9537e86a9ea3b317060e15f07818b245ceb..e16460d869c1c15588f8f668ace7ea000af5f8be 100644 (file)
@@ -17,10 +17,14 @@ New strategies can be added via new ``EngineStrategy`` classes.
 
 from operator import attrgetter
 
-from sqlalchemy.engine import base, threadlocal, url
-from sqlalchemy import util, event
-from sqlalchemy import pool as poollib
-from sqlalchemy.sql import schema
+from . import base
+from . import threadlocal
+from . import url
+from .. import event
+from .. import pool as poollib
+from .. import util
+from ..sql import schema
+
 
 strategies = {}
 
@@ -299,7 +303,7 @@ class MockEngineStrategy(EngineStrategy):
                 element
             )
 
-        def execute(self, object, *multiparams, **params):
+        def execute(self, object_, *multiparams, **params):
             raise NotImplementedError()
 
 
index 5b2bdabc0930b4e0535ccb1239fa14777fc8d4ef..b34d510f71c40cd8be86b30d13909f850eb7d1e6 100644 (file)
@@ -13,10 +13,11 @@ This module is semi-private and is invoked automatically when the threadlocal
 engine strategy is used.
 """
 
-from .. import util
-from . import base
 import weakref
 
+from . import base
+from .. import util
+
 
 class TLConnection(base.Connection):
     def __init__(self, *arg, **kw):
@@ -92,8 +93,8 @@ class TLEngine(base.Engine):
     def __enter__(self):
         return self
 
-    def __exit__(self, type, value, traceback):
-        if type is None:
+    def __exit__(self, type_, value, traceback):
+        if type_ is None:
             self.commit()
         else:
             self.rollback()
index e92e57b8e3ed5222bd8b0634c9cc1e6b9947959e..f7019d74e3a2dcc2aae382387cca57dca5977b73 100644 (file)
@@ -15,9 +15,12 @@ be used directly and is also accepted directly by ``create_engine()``.
 """
 
 import re
-from .. import exc, util
-from . import Dialect
-from ..dialects import registry, plugins
+
+from .interfaces import Dialect
+from .. import exc
+from .. import util
+from ..dialects import plugins
+from ..dialects import registry
 
 
 class URL(object):
index 76bb8f4b547c3cd0fe0716200b57922dd6df71b3..bf8ec13b9e19c687f68deb21a0faf2a3bbea0bc7 100644 (file)
@@ -28,8 +28,8 @@ def connection_memoize(key):
 
 
 def py_fallback():
-    def _distill_params(multiparams, params):
-        """Given arguments from the calling form *multiparams, **params,
+    def _distill_params(multiparams, params):  # noqa
+        r"""Given arguments from the calling form \*multiparams, \**params,
         return a list of bind parameter structures, usually a list of
         dictionaries.
 
@@ -75,6 +75,6 @@ def py_fallback():
 
 
 try:
-    from sqlalchemy.cutils import _distill_params
+    from sqlalchemy.cutils import _distill_params  # noqa
 except ImportError:
     globals().update(py_fallback())
index a7e27e9b6196405aab15dbc28c2a32e3d0dd94ae..d38a5e94894538610e871dabc324163e3f25f256 100644 (file)
@@ -5,7 +5,13 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from .api import CANCEL, NO_RETVAL, listen, listens_for, remove, contains
-from .base import Events, dispatcher
-from .attr import RefCollection
-from .legacy import _legacy_signature
+from .api import CANCEL  # noqa
+from .api import contains  # noqa
+from .api import listen  # noqa
+from .api import listens_for  # noqa
+from .api import NO_RETVAL  # noqa
+from .api import remove  # noqa
+from .attr import RefCollection  # noqa
+from .base import dispatcher  # noqa
+from .base import Events  # noqa
+from .legacy import _legacy_signature  # noqa
index f9e04503c61c32d85c0fb5b12168013aecbe61df..4064b3e21d32a47df6d0f2a88426aa366c7b482c 100644 (file)
 """
 from __future__ import absolute_import
 
-from .. import util, exc
 from .base import _registrars
 from .registry import _EventKey
+from .. import exc
+from .. import util
+
 
 CANCEL = util.symbol("CANCEL")
 NO_RETVAL = util.symbol("NO_RETVAL")
index 31a9f28ca48e9c1e8b079a8c577ce2d5d3227e33..451e0621a563151379c81c99fe72e50aadc9b397 100644 (file)
@@ -29,15 +29,18 @@ as well as support for subclass propagation (e.g. events assigned to
 
 """
 
-from __future__ import absolute_import, with_statement
+from __future__ import absolute_import
+from __future__ import with_statement
+
+import collections
+from itertools import chain
+import weakref
+
+from . import legacy
+from . import registry
 from .. import exc
 from .. import util
 from ..util import threading
-from . import registry
-from . import legacy
-from itertools import chain
-import weakref
-import collections
 
 
 class RefCollection(util.MemoizedSlots):
index c750be70ac9966afac5ab5af3aa6f641185d6874..6e30272142529e9d2648dddc962022a337a804c0 100644 (file)
@@ -19,8 +19,11 @@ from __future__ import absolute_import
 
 import weakref
 
+from .attr import _ClsLevelDispatch
+from .attr import _EmptyListener
+from .attr import _JoinedListener
 from .. import util
-from .attr import _ClsLevelDispatch, _EmptyListener, _JoinedListener
+
 
 _registrars = util.defaultdict(list)
 
index c862ae403305bf7d126be874d40b3241af13f753..86d3239824b7b9c35c04a493ddd6f4598a0d0f46 100644 (file)
@@ -17,10 +17,12 @@ an equivalent :class:`._EventKey`.
 
 from __future__ import absolute_import
 
-import weakref
 import collections
 import types
-from .. import exc, util
+import weakref
+
+from .. import exc
+from .. import util
 
 
 _key_to_collection = collections.defaultdict(dict)
@@ -236,11 +238,7 @@ class _EventKey(object):
         self, propagate=False, insert=False, named=False, retval=None
     ):
 
-        target, identifier, fn = (
-            self.dispatch_target,
-            self.identifier,
-            self._listen_fn,
-        )
+        target, identifier = self.dispatch_target, self.identifier
 
         dispatch_collection = getattr(target.dispatch, identifier)
 
index fa62b77056ada282b796db666a482b5d70d07d24..01e7b454b57c8f0a857c6baceacbb189d0ddb6fa 100644 (file)
@@ -7,9 +7,12 @@
 
 """Core event interfaces."""
 
-from . import event, exc
+from . import event
+from . import exc
+from .engine import Connectable
+from .engine import Dialect
+from .engine import Engine
 from .pool import Pool
-from .engine import Connectable, Engine, Dialect
 from .sql.base import SchemaEventTarget
 
 
@@ -912,11 +915,12 @@ class ConnectionEvents(event.Events):
             :meth:`.ConnectionEvents.handle_error` hook.
 
         .. versionchanged:: 1.1 The :meth:`.handle_error` event will now
-           receive all exceptions that inherit from ``BaseException``, including
-           ``SystemExit`` and ``KeyboardInterrupt``.  The setting for
-           :attr:`.ExceptionContext.is_disconnect` is ``True`` in this case
-           and the default for :attr:`.ExceptionContext.invalidate_pool_on_disconnect`
-           is ``False``.
+           receive all exceptions that inherit from ``BaseException``,
+           including ``SystemExit`` and ``KeyboardInterrupt``.  The setting for
+           :attr:`.ExceptionContext.is_disconnect` is ``True`` in this case and
+           the default for
+           :attr:`.ExceptionContext.invalidate_pool_on_disconnect` is
+           ``False``.
 
         .. versionchanged:: 1.0.0 The :meth:`.handle_error` event is now
            invoked when an :class:`.Engine` fails during the initial
@@ -1191,11 +1195,7 @@ class DialectEvents(event.Events):
 
     @classmethod
     def _listen(cls, event_key, retval=False):
-        target, identifier, fn = (
-            event_key.dispatch_target,
-            event_key.identifier,
-            event_key.fn,
-        )
+        target = event_key.dispatch_target
 
         target._has_events = True
         event_key.base_listen()
index 832c5ee524c2127bd0146fbe7e342ee5f98938c0..e47df85af344a514ed704205328e9517f17c950d 100644 (file)
@@ -179,7 +179,7 @@ class InvalidatePoolError(DisconnectionError):
     invalidate_pool = True
 
 
-class TimeoutError(SQLAlchemyError):
+class TimeoutError(SQLAlchemyError):  # noqa
     """Raised when a connection pool times out on getting a connection."""
 
 
index 9fed09e2bfc4ea66fb9595c5863b68c728f50158..7219b28a599e67c74418df2a1ce7d53be91ef152 100644 (file)
@@ -7,4 +7,5 @@
 
 from .. import util as _sa_util
 
+
 _sa_util.dependencies.resolve_all("sqlalchemy.ext")
index 56b91ce0bbdb742dab5cd3e027ec385084169d75..36c3fd415fa3559fa0e07b1ae2c3fdc4a7225971 100644 (file)
@@ -14,11 +14,15 @@ See the example ``examples/association/proxied_association.py``.
 
 """
 import operator
-from .. import exc, orm, util
-from ..orm import collections, interfaces
+
+from .. import exc
+from .. import inspect
+from .. import orm
+from .. import util
+from ..orm import collections
+from ..orm import interfaces
 from ..sql import or_
 from ..sql.operators import ColumnOperators
-from .. import inspect
 
 
 def association_proxy(target_collection, attr, **kw):
@@ -316,7 +320,7 @@ class AssociationProxyInstance(object):
 
     .. versionadded:: 1.3
 
-    """
+    """  # noqa
 
     def __init__(self, parent, owning_class, target_class, value_attr):
         self.parent = parent
@@ -478,10 +482,10 @@ class AssociationProxyInstance(object):
 
     def _initialize_scalar_accessors(self):
         if self.parent.getset_factory:
-            get, set = self.parent.getset_factory(None, self)
+            get, set_ = self.parent.getset_factory(None, self)
         else:
-            get, set = self.parent._default_getset(None)
-        self._scalar_get, self._scalar_set = get, set
+            get, set_ = self.parent._default_getset(None)
+        self._scalar_get, self._scalar_set = get, set_
 
     def _default_getset(self, collection_class):
         attr = self.value_attr
@@ -954,11 +958,11 @@ class _AssociationList(_AssociationCollection):
     def _create(self, value):
         return self.creator(value)
 
-    def _get(self, object):
-        return self.getter(object)
+    def _get(self, object_):
+        return self.getter(object_)
 
-    def _set(self, object, value):
-        return self.setter(object, value)
+    def _set(self, object_, value):
+        return self.setter(object_, value)
 
     def __getitem__(self, index):
         if not isinstance(index, slice):
@@ -1164,11 +1168,11 @@ class _AssociationDict(_AssociationCollection):
     def _create(self, key, value):
         return self.creator(key, value)
 
-    def _get(self, object):
-        return self.getter(object)
+    def _get(self, object_):
+        return self.getter(object_)
 
-    def _set(self, object, key, value):
-        return self.setter(object, key, value)
+    def _set(self, object_, key, value):
+        return self.setter(object_, key, value)
 
     def __getitem__(self, key):
         return self._get(self.col[key])
@@ -1321,8 +1325,8 @@ class _AssociationSet(_AssociationCollection):
     def _create(self, value):
         return self.creator(value)
 
-    def _get(self, object):
-        return self.getter(object)
+    def _get(self, object_):
+        return self.getter(object_)
 
     def __len__(self):
         return len(self.col)
index 747373a2a43cb0094074bcb6dfc870e1f94fce88..60cc4dfe021de91b9f32546931a939379475cfe9 100644 (file)
@@ -512,14 +512,16 @@ the :meth:`.AutomapBase.prepare` method is required; if not called, the classes
 we've declared are in an un-mapped state.
 
 
-"""
+"""  # noqa
 from .declarative import declarative_base as _declarative_base
 from .declarative.base import _DeferredMapperConfig
-from ..sql import and_
-from ..schema import ForeignKeyConstraint
-from ..orm import relationship, backref, interfaces
-from ..orm.mapper import _CONFIGURE_MUTEX
 from .. import util
+from ..orm import backref
+from ..orm import interfaces
+from ..orm import relationship
+from ..orm.mapper import _CONFIGURE_MUTEX
+from ..schema import ForeignKeyConstraint
+from ..sql import and_
 
 
 def classname_for_table(base, tablename, table):
index f55231a091696dade797482b5c7c7b5c730bcd0b..4feba8959f7226a9e9f9e1cff637fdfcac566e02 100644 (file)
@@ -13,16 +13,19 @@ compiled result to be fully cached.
 
 """
 
-from ..orm.query import Query
-from ..orm import strategy_options
-from ..orm.session import Session
-from ..sql import util as sql_util, func, literal_column
-from ..orm import exc as orm_exc
+import copy
+import logging
+
 from .. import exc as sa_exc
 from .. import util
+from ..orm import exc as orm_exc
+from ..orm import strategy_options
+from ..orm.query import Query
+from ..orm.session import Session
+from ..sql import func
+from ..sql import literal_column
+from ..sql import util as sql_util
 
-import copy
-import logging
 
 log = logging.getLogger(__name__)
 
index 2b0a37884a7ffa388ed658038ddbfdf8441479bf..5eb6ebb2e3cba436d8672a78ff7dcea629b1485c 100644 (file)
@@ -5,19 +5,17 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from .api import (
-    declarative_base,
-    synonym_for,
-    comparable_using,
-    instrument_declarative,
-    ConcreteBase,
-    AbstractConcreteBase,
-    DeclarativeMeta,
-    DeferredReflection,
-    has_inherited_table,
-    declared_attr,
-    as_declarative,
-)
+from .api import AbstractConcreteBase
+from .api import as_declarative
+from .api import comparable_using
+from .api import ConcreteBase
+from .api import declarative_base
+from .api import DeclarativeMeta
+from .api import declared_attr
+from .api import DeferredReflection
+from .api import has_inherited_table
+from .api import instrument_declarative
+from .api import synonym_for
 
 
 __all__ = [
index 987e92119683eec9e928347aa685ad1523ba5902..a4cbf3b5255da18e9363ad47b0d331a3a1db4b86 100644 (file)
@@ -7,30 +7,29 @@
 """Public API functions and helpers for declarative."""
 
 
-from ...schema import Table, MetaData, Column
-from ...orm import (
-    synonym as _orm_synonym,
-    comparable_property,
-    interfaces,
-    properties,
-    attributes,
-)
-from ...orm.util import polymorphic_union
-from ...orm.base import _mapper_or_none
-from ...util import OrderedDict, hybridmethod, hybridproperty
-from ... import util
-from ... import exc
-import weakref
 import re
+import weakref
 
-from .base import (
-    _as_declarative,
-    _declarative_constructor,
-    _DeferredMapperConfig,
-    _add_attribute,
-    _del_attribute,
-)
+from .base import _add_attribute
+from .base import _as_declarative
+from .base import _declarative_constructor
+from .base import _DeferredMapperConfig
+from .base import _del_attribute
 from .clsregistry import _class_resolver
+from ... import exc
+from ... import util
+from ...orm import attributes
+from ...orm import comparable_property
+from ...orm import interfaces
+from ...orm import properties
+from ...orm import synonym as _orm_synonym
+from ...orm.base import _mapper_or_none
+from ...orm.util import polymorphic_union
+from ...schema import MetaData
+from ...schema import Table
+from ...util import hybridmethod
+from ...util import hybridproperty
+from ...util import OrderedDict
 
 
 def instrument_declarative(cls, registry, metadata):
@@ -258,7 +257,8 @@ class declared_attr(interfaces._MappedAttribute, property):
                 @declared_attr.cascading
                 def id(cls):
                     if has_inherited_table(cls):
-                        return Column(ForeignKey('myclass.id'), primary_key=True)
+                        return Column(
+                            ForeignKey('myclass.id'), primary_key=True)
                     else:
                         return Column(Integer, primary_key=True)
 
@@ -362,8 +362,9 @@ def declarative_base(
       compatible callable to use as the meta type of the generated
       declarative base class.
 
-    .. versionchanged:: 1.1 if :paramref:`.declarative_base.cls` is a single class (rather
-         than a tuple), the constructed base class will inherit its docstring.
+    .. versionchanged:: 1.1 if :paramref:`.declarative_base.cls` is a
+         single class (rather than a tuple), the constructed base class will
+         inherit its docstring.
 
     .. seealso::
 
index 07778f733c6118bb665e86bd1e0d87c07cb70d49..3c83b0b0e8627b66e23a2e2e24b8ce536b42f695 100644 (file)
@@ -6,20 +6,28 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 """Internal implementation for declarative."""
 
-from ...schema import Table, Column
-from ...orm import mapper, class_mapper, synonym
-from ...orm.interfaces import MapperProperty
-from ...orm.properties import ColumnProperty, CompositeProperty
-from ...orm.attributes import QueryableAttribute
-from ...orm.base import _is_mapped_class, InspectionAttr
-from ... import util, exc
-from ...util import topological
-from ...sql import expression
-from ... import event
-from . import clsregistry
 import collections
 import weakref
+
 from sqlalchemy.orm import instrumentation
+from . import clsregistry
+from ... import event
+from ... import exc
+from ... import util
+from ...orm import class_mapper
+from ...orm import mapper
+from ...orm import synonym
+from ...orm.attributes import QueryableAttribute
+from ...orm.base import _is_mapped_class
+from ...orm.base import InspectionAttr
+from ...orm.interfaces import MapperProperty
+from ...orm.properties import ColumnProperty
+from ...orm.properties import CompositeProperty
+from ...schema import Column
+from ...schema import Table
+from ...sql import expression
+from ...util import topological
+
 
 declared_attr = declarative_props = None
 
@@ -228,9 +236,9 @@ class _MapperConfig(object):
                         # make a copy of it so a class-level dictionary
                         # is not overwritten when we update column-based
                         # arguments.
-                        mapper_args_fn = lambda: dict(
-                            cls.__mapper_args__
-                        )  # noqa
+                        def mapper_args_fn():
+                            return dict(cls.__mapper_args__)
+
                 elif name == "__tablename__":
                     check_decl = _check_declared_props_nocascade(
                         obj, name, cls
@@ -283,8 +291,9 @@ class _MapperConfig(object):
                                 # defined attribute here to allow a clean
                                 # override, if there's another
                                 # subclass below then it still tries to use
-                                # this.  not sure if there is enough information
-                                # here to add this as a feature later on.
+                                # this.  not sure if there is enough
+                                # information here to add this as a feature
+                                # later on.
                                 util.warn(
                                     "Attribute '%s' on class %s cannot be "
                                     "processed due to "
index c52ae4a2f15a16b7ea9c5dc44f98d1532dfc42e0..6f7c7c2beac62a83e83b4be7e863fb402855a191 100644 (file)
@@ -10,18 +10,19 @@ This system allows specification of classes and expressions used in
 :func:`.relationship` using strings.
 
 """
-from ...orm.properties import (
-    ColumnProperty,
-    RelationshipProperty,
-    SynonymProperty,
-)
-from ...schema import _get_table_key
-from ...orm import class_mapper, interfaces
-from ... import util
-from ... import inspection
-from ... import exc
 import weakref
 
+from ... import exc
+from ... import inspection
+from ... import util
+from ...orm import class_mapper
+from ...orm import interfaces
+from ...orm.properties import ColumnProperty
+from ...orm.properties import RelationshipProperty
+from ...orm.properties import SynonymProperty
+from ...schema import _get_table_key
+
+
 # strong references to registries which we place in
 # the _decl_class_registry, which is usually weak referencing.
 # the internal registries here link to classes with weakrefs and remove
index 7248e5b4da21a77e95fd0bcfa789999c37d65e0e..dda0bc5bad3170747f38fa3814a5acc6b77f765a 100644 (file)
@@ -17,8 +17,9 @@ the source distribution.
 
 from .. import inspect
 from .. import util
-from ..orm.session import Session
 from ..orm.query import Query
+from ..orm.session import Session
+
 
 __all__ = ["ShardedSession", "ShardedQuery"]
 
index d51a083da71808afeface6c042f51d0e307098bc..729fe1202ec26d7f5afd83c0a0f21ac8a64ca3a3 100644 (file)
@@ -16,8 +16,8 @@ dependencies on the rest of SQLAlchemy.  It can, in theory, work with
 any descriptor-based expression system.
 
 Consider a mapping ``Interval``, representing integer ``start`` and ``end``
-values. We can define higher level functions on mapped classes that produce
-SQL expressions at the class level, and Python expression evaluation at the
+values. We can define higher level functions on mapped classes that produce SQL
+expressions at the class level, and Python expression evaluation at the
 instance level.  Below, each function decorated with :class:`.hybrid_method` or
 :class:`.hybrid_property` may receive ``self`` as an instance of the class, or
 as the class itself::
@@ -410,7 +410,8 @@ idiosyncratic behavior on the SQL side.
 
 .. note::  The :meth:`.hybrid_property.comparator` decorator introduced
    in this section **replaces** the use of the
-   :meth:`.hybrid_property.expression` decorator.  They cannot be used together.
+   :meth:`.hybrid_property.expression` decorator.
+   They cannot be used together.
 
 The example class below allows case-insensitive comparisons on the attribute
 named ``word_insensitive``::
@@ -496,13 +497,12 @@ Above, the ``FirstNameLastName`` class refers to the hybrid from
 ``FirstNameOnly.name`` to repurpose its getter and setter for the subclass.
 
 When overriding :meth:`.hybrid_property.expression` and
-:meth:`.hybrid_property.comparator` alone as the first reference
-to the superclass, these names conflict
-with the same-named accessors on the class-level :class:`.QueryableAttribute`
-object returned at the class level.  To override these methods when
-referring directly to the parent class descriptor, add
-the special qualifier :attr:`.hybrid_property.overrides`, which will
-de-reference the instrumented attribute back to the hybrid object::
+:meth:`.hybrid_property.comparator` alone as the first reference to the
+superclass, these names conflict with the same-named accessors on the class-
+level :class:`.QueryableAttribute` object returned at the class level.  To
+override these methods when referring directly to the parent class descriptor,
+add the special qualifier :attr:`.hybrid_property.overrides`, which will de-
+reference the instrumented attribute back to the hybrid object::
 
     class FirstNameLastName(FirstNameOnly):
         # ...
@@ -520,19 +520,18 @@ de-reference the instrumented attribute back to the hybrid object::
 Hybrid Value Objects
 --------------------
 
-Note in our previous example, if we were to compare the
-``word_insensitive`` attribute of a ``SearchWord`` instance to a plain
-Python string, the plain Python string would not be coerced to lower
-case - the ``CaseInsensitiveComparator`` we built, being returned by
+Note in our previous example, if we were to compare the ``word_insensitive``
+attribute of a ``SearchWord`` instance to a plain Python string, the plain
+Python string would not be coerced to lower case - the
+``CaseInsensitiveComparator`` we built, being returned by
 ``@word_insensitive.comparator``, only applies to the SQL side.
 
-A more comprehensive form of the custom comparator is to construct a
-*Hybrid Value Object*. This technique applies the target value or
-expression to a value object which is then returned by the accessor in
-all cases.   The value object allows control of all operations upon
-the value as well as how compared values are treated, both on the SQL
-expression side as well as the Python value side.   Replacing the
-previous ``CaseInsensitiveComparator`` class with a new
+A more comprehensive form of the custom comparator is to construct a *Hybrid
+Value Object*. This technique applies the target value or expression to a value
+object which is then returned by the accessor in all cases.   The value object
+allows control of all operations upon the value as well as how compared values
+are treated, both on the SQL expression side as well as the Python value side.
+Replacing the previous ``CaseInsensitiveComparator`` class with a new
 ``CaseInsensitiveWord`` class::
 
     class CaseInsensitiveWord(Comparator):
@@ -560,13 +559,12 @@ previous ``CaseInsensitiveComparator`` class with a new
         key = 'word'
         "Label to apply to Query tuple results"
 
-Above, the ``CaseInsensitiveWord`` object represents ``self.word``,
-which may be a SQL function, or may be a Python native.   By
-overriding ``operate()`` and ``__clause_element__()`` to work in terms
-of ``self.word``, all comparison operations will work against the
-"converted" form of ``word``, whether it be SQL side or Python side.
-Our ``SearchWord`` class can now deliver the ``CaseInsensitiveWord``
-object unconditionally from a single hybrid call::
+Above, the ``CaseInsensitiveWord`` object represents ``self.word``, which may
+be a SQL function, or may be a Python native.   By overriding ``operate()`` and
+``__clause_element__()`` to work in terms of ``self.word``, all comparison
+operations will work against the "converted" form of ``word``, whether it be
+SQL side or Python side. Our ``SearchWord`` class can now deliver the
+``CaseInsensitiveWord`` object unconditionally from a single hybrid call::
 
     class SearchWord(Base):
         __tablename__ = 'searchword'
@@ -577,10 +575,9 @@ object unconditionally from a single hybrid call::
         def word_insensitive(self):
             return CaseInsensitiveWord(self.word)
 
-The ``word_insensitive`` attribute now has case-insensitive comparison
-behavior universally, including SQL expression vs. Python expression
-(note the Python value is converted to lower case on the Python side
-here)::
+The ``word_insensitive`` attribute now has case-insensitive comparison behavior
+universally, including SQL expression vs. Python expression (note the Python
+value is converted to lower case on the Python side here)::
 
     >>> print Session().query(SearchWord).filter_by(word_insensitive="Trucks")
     SELECT searchword.id AS searchword_id, searchword.word AS searchword_word
@@ -612,9 +609,9 @@ Python only expression::
     >>> print ws1.word_insensitive
     someword
 
-The Hybrid Value pattern is very useful for any kind of value that may
-have multiple representations, such as timestamps, time deltas, units
-of measurement, currencies and encrypted passwords.
+The Hybrid Value pattern is very useful for any kind of value that may have
+multiple representations, such as timestamps, time deltas, units of
+measurement, currencies and encrypted passwords.
 
 .. seealso::
 
@@ -631,17 +628,17 @@ of measurement, currencies and encrypted passwords.
 Building Transformers
 ----------------------
 
-A *transformer* is an object which can receive a :class:`.Query`
-object and return a new one.   The :class:`.Query` object includes a
-method :meth:`.with_transformation` that returns a new :class:`.Query`
-transformed by the given function.
+A *transformer* is an object which can receive a :class:`.Query` object and
+return a new one.   The :class:`.Query` object includes a method
+:meth:`.with_transformation` that returns a new :class:`.Query` transformed by
+the given function.
 
 We can combine this with the :class:`.Comparator` class to produce one type
 of recipe which can both set up the FROM clause of a query as well as assign
 filtering criterion.
 
-Consider a mapped class ``Node``, which assembles using adjacency list
-into a hierarchical tree pattern::
+Consider a mapped class ``Node``, which assembles using adjacency list into a
+hierarchical tree pattern::
 
     from sqlalchemy import Column, Integer, ForeignKey
     from sqlalchemy.orm import relationship
@@ -654,9 +651,9 @@ into a hierarchical tree pattern::
         parent_id = Column(Integer, ForeignKey('node.id'))
         parent = relationship("Node", remote_side=id)
 
-Suppose we wanted to add an accessor ``grandparent``.  This would
-return the ``parent`` of ``Node.parent``.  When we have an instance of
-``Node``, this is simple::
+Suppose we wanted to add an accessor ``grandparent``.  This would return the
+``parent`` of ``Node.parent``.  When we have an instance of ``Node``, this is
+simple::
 
     from sqlalchemy.ext.hybrid import hybrid_property
 
@@ -667,13 +664,12 @@ return the ``parent`` of ``Node.parent``.  When we have an instance of
         def grandparent(self):
             return self.parent.parent
 
-For the expression, things are not so clear.   We'd need to construct
-a :class:`.Query` where we :meth:`~.Query.join` twice along
-``Node.parent`` to get to the ``grandparent``.   We can instead return
-a transforming callable that we'll combine with the
-:class:`.Comparator` class to receive any :class:`.Query` object, and
-return a new one that's joined to the ``Node.parent`` attribute and
-filtered based on the given criterion::
+For the expression, things are not so clear.   We'd need to construct a
+:class:`.Query` where we :meth:`~.Query.join` twice along ``Node.parent`` to
+get to the ``grandparent``.   We can instead return a transforming callable
+that we'll combine with the :class:`.Comparator` class to receive any
+:class:`.Query` object, and return a new one that's joined to the
+``Node.parent`` attribute and filtered based on the given criterion::
 
     from sqlalchemy.ext.hybrid import Comparator
 
@@ -702,17 +698,15 @@ filtered based on the given criterion::
         def grandparent(cls):
             return GrandparentTransformer(cls)
 
-The ``GrandparentTransformer`` overrides the core
-:meth:`.Operators.operate` method at the base of the
-:class:`.Comparator` hierarchy to return a query-transforming
-callable, which then runs the given comparison operation in a
-particular context. Such as, in the example above, the ``operate``
-method is called, given the :attr:`.Operators.eq` callable as well as
-the right side of the comparison ``Node(id=5)``.  A function
-``transform`` is then returned which will transform a :class:`.Query`
-first to join to ``Node.parent``, then to compare ``parent_alias``
-using :attr:`.Operators.eq` against the left and right sides, passing
-into :class:`.Query.filter`:
+The ``GrandparentTransformer`` overrides the core :meth:`.Operators.operate`
+method at the base of the :class:`.Comparator` hierarchy to return a query-
+transforming callable, which then runs the given comparison operation in a
+particular context. Such as, in the example above, the ``operate`` method is
+called, given the :attr:`.Operators.eq` callable as well as the right side of
+the comparison ``Node(id=5)``.  A function ``transform`` is then returned which
+will transform a :class:`.Query` first to join to ``Node.parent``, then to
+compare ``parent_alias`` using :attr:`.Operators.eq` against the left and right
+sides, passing into :class:`.Query.filter`:
 
 .. sourcecode:: pycon+sql
 
@@ -726,12 +720,12 @@ into :class:`.Query.filter`:
     WHERE :param_1 = node_1.parent_id
     {stop}
 
-We can modify the pattern to be more verbose but flexible by separating
-the "join" step from the "filter" step.  The tricky part here is ensuring
-that successive instances of ``GrandparentTransformer`` use the same
+We can modify the pattern to be more verbose but flexible by separating the
+"join" step from the "filter" step.  The tricky part here is ensuring that
+successive instances of ``GrandparentTransformer`` use the same
 :class:`.AliasedClass` object against ``Node``.  Below we use a simple
-memoizing approach that associates a ``GrandparentTransformer``
-with each class::
+memoizing approach that associates a ``GrandparentTransformer`` with each
+class::
 
     class Node(Base):
 
@@ -769,14 +763,16 @@ with each class::
     WHERE :param_1 = node_1.parent_id
     {stop}
 
-The "transformer" pattern is an experimental pattern that starts
-to make usage of some functional programming paradigms.
-While it's only recommended for advanced and/or patient developers,
-there's probably a whole lot of amazing things it can be used for.
+The "transformer" pattern is an experimental pattern that starts to make usage
+of some functional programming paradigms. While it's only recommended for
+advanced and/or patient developers, there's probably a whole lot of amazing
+things it can be used for.
 
-"""
+"""  # noqa
 from .. import util
-from ..orm import attributes, interfaces
+from ..orm import attributes
+from ..orm import interfaces
+
 
 HYBRID_METHOD = util.symbol("HYBRID_METHOD")
 """Symbol indicating an :class:`InspectionAttr` that's
index 368e5b00ae1dd97e2e9dec4e78d53c91c1830e00..a9100728e54cb60a63272bf71abc7c124706ff9b 100644 (file)
@@ -174,10 +174,6 @@ data structure does not exist, and a set operation is called:
   rules.
 
 
-
-
-
-
 Subclassing
 ===========
 
@@ -224,12 +220,12 @@ The above query will render::
     FROM person
     WHERE CAST(person.data ->> %(data_1)s AS INTEGER) < %(param_1)s
 
-"""
+"""  # noqa
 from __future__ import absolute_import
 
 from sqlalchemy import inspect
-from ..orm.attributes import flag_modified
 from ..ext.hybrid import hybrid_property
+from ..orm.attributes import flag_modified
 
 
 __all__ = ["index_property"]
index b2b8dd7c5d1b16b05c69b0f568cd2b98a875af96..ae62dca08e7d400b600f745356e813a6e49d417e 100644 (file)
@@ -26,18 +26,20 @@ see the example :ref:`examples_instrumentation`.
    being used to determine class instrumentation resolution.
 
 """
-from ..orm import instrumentation as orm_instrumentation
-from ..orm.instrumentation import (
-    ClassManager,
-    InstrumentationFactory,
-    _default_state_getter,
-    _default_dict_getter,
-    _default_manager_getter,
-)
-from ..orm import attributes, collections, base as orm_base
+import weakref
+
 from .. import util
+from ..orm import attributes
+from ..orm import base as orm_base
+from ..orm import collections
 from ..orm import exc as orm_exc
-import weakref
+from ..orm import instrumentation as orm_instrumentation
+from ..orm.instrumentation import _default_dict_getter
+from ..orm.instrumentation import _default_manager_getter
+from ..orm.instrumentation import _default_state_getter
+from ..orm.instrumentation import ClassManager
+from ..orm.instrumentation import InstrumentationFactory
+
 
 INSTRUMENTATION_MANAGER = "__sa_instrumentation_manager__"
 """Attribute, elects custom instrumentation when present on a mapped class.
index 0f6ccdc333f144c781b7e64d00636d9a03efec99..96372639f5f1cab64c2d6127525511b02e106635 100644 (file)
@@ -370,12 +370,16 @@ pickling process of the parent's object-relational state so that the
 :meth:`MutableBase._parents` collection is restored to all ``Point`` objects.
 
 """
+import weakref
+
+from .. import event
+from .. import types
+from ..orm import Mapper
+from ..orm import mapper
+from ..orm import object_mapper
 from ..orm.attributes import flag_modified
-from .. import event, types
-from ..orm import mapper, object_mapper, Mapper
-from ..util import memoized_property
 from ..sql.base import SchemaEventTarget
-import weakref
+from ..util import memoized_property
 
 
 class MutableBase(object):
@@ -479,7 +483,7 @@ class MutableBase(object):
             if not attrs or listen_keys.intersection(attrs):
                 load(state)
 
-        def set(target, value, oldvalue, initiator):
+        def set_(target, value, oldvalue, initiator):
             """Listen for set/replace events on the target
             data member.
 
@@ -519,7 +523,7 @@ class MutableBase(object):
             parent_cls, "refresh_flush", load_attrs, raw=True, propagate=True
         )
         event.listen(
-            attribute, "set", set, raw=True, retval=True, propagate=True
+            attribute, "set", set_, raw=True, retval=True, propagate=True
         )
         event.listen(parent_cls, "pickle", pickle, raw=True, propagate=True)
         event.listen(
index 2a8522120bfd1ae13c46de136de7249b1ac5ca1d..65921104454237a9babcc981bc7760e8d7149f6a 100644 (file)
@@ -119,8 +119,10 @@ start numbering at 1 or some other integer, provide ``count_from=1``.
 
 
 """
-from ..orm.collections import collection, collection_adapter
 from .. import util
+from ..orm.collections import collection
+from ..orm.collections import collection_adapter
+
 
 __all__ = ["ordering_list"]
 
index 3adcec34f411553397e9ca17872f13183df17822..ae983946a969e26aaea0315da53468fd069befbf 100644 (file)
@@ -53,15 +53,21 @@ needed for:
 
 """
 
+import re
+
+from .. import Column
+from .. import Table
+from ..engine import Engine
 from ..orm import class_mapper
-from ..orm.session import Session
-from ..orm.mapper import Mapper
-from ..orm.interfaces import MapperProperty
 from ..orm.attributes import QueryableAttribute
-from .. import Table, Column
-from ..engine import Engine
-from ..util import pickle, byte_buffer, b64encode, b64decode, text_type
-import re
+from ..orm.interfaces import MapperProperty
+from ..orm.mapper import Mapper
+from ..orm.session import Session
+from ..util import b64decode
+from ..util import b64encode
+from ..util import byte_buffer
+from ..util import pickle
+from ..util import text_type
 
 
 __all__ = ["Serializer", "Deserializer", "dumps", "loads"]
@@ -75,29 +81,29 @@ def Serializer(*args, **kw):
         if isinstance(obj, QueryableAttribute):
             cls = obj.impl.class_
             key = obj.impl.key
-            id = "attribute:" + key + ":" + b64encode(pickle.dumps(cls))
+            id_ = "attribute:" + key + ":" + b64encode(pickle.dumps(cls))
         elif isinstance(obj, Mapper) and not obj.non_primary:
-            id = "mapper:" + b64encode(pickle.dumps(obj.class_))
+            id_ = "mapper:" + b64encode(pickle.dumps(obj.class_))
         elif isinstance(obj, MapperProperty) and not obj.parent.non_primary:
-            id = (
+            id_ = (
                 "mapperprop:"
                 + b64encode(pickle.dumps(obj.parent.class_))
                 + ":"
                 + obj.key
             )
         elif isinstance(obj, Table):
-            id = "table:" + text_type(obj.key)
+            id_ = "table:" + text_type(obj.key)
         elif isinstance(obj, Column) and isinstance(obj.table, Table):
-            id = (
+            id_ = (
                 "column:" + text_type(obj.table.key) + ":" + text_type(obj.key)
             )
         elif isinstance(obj, Session):
-            id = "session:"
+            id_ = "session:"
         elif isinstance(obj, Engine):
-            id = "engine:"
+            id_ = "engine:"
         else:
             return None
-        return id
+        return id_
 
     pickler.persistent_id = persistent_id
     return pickler
@@ -121,8 +127,8 @@ def Deserializer(file, metadata=None, scoped_session=None, engine=None):
         else:
             return None
 
-    def persistent_load(id):
-        m = our_ids.match(text_type(id))
+    def persistent_load(id_):
+        m = our_ids.match(text_type(id_))
         if not m:
             return None
         else:
index 7c2ff97c57b9cd3b9422a50b84a9d86c8ebd5137..6b6bcd688e5effac7ea68c41beb78e2f3930c88e 100644 (file)
@@ -31,7 +31,9 @@ in a forwards-compatible way.
 
 """
 
-from . import util, exc
+from . import exc
+from . import util
+
 
 _registrars = util.defaultdict(list)
 
index f352f7f26303a16bde986301df819714ef202ad9..bde854d24ca2605aff290a5aae0658bb576993bc 100644 (file)
@@ -13,7 +13,8 @@ event system.
 
 """
 
-from . import event, util
+from . import event
+from . import util
 
 
 class PoolListener(object):
index 6b0b2e90ef7697f24e0e9616cbe37db3a3ad1a22..45073ad9297b83970afe010db24b4773b067428a 100644 (file)
@@ -21,6 +21,7 @@ instance only.
 import logging
 import sys
 
+
 # set initial level to WARN.  This so that
 # log statements don't occur in the absence of explicit
 # logging being enabled for 'sqlalchemy'.
@@ -73,8 +74,8 @@ class InstanceLogger(object):
 
     'debug' -> logging.DEBUG
     True    -> logging.INFO
-    False   -> Effective level of underlying logger
-               (logging.WARNING by default)
+    False   -> Effective level of underlying logger (
+    logging.WARNING by default)
     None    -> same as False
     """
 
index 8e7b4cee652f82ab0103fc5006dce56050e695a4..d9f50e1532a26451f268812cad072551dde82b3a 100644 (file)
@@ -13,53 +13,50 @@ documentation for an overview of how this module is used.
 
 """
 
-from . import exc
-from .mapper import (
-    Mapper,
-    _mapper_registry,
-    class_mapper,
-    configure_mappers,
-    reconstructor,
-    validates,
-)
-from .interfaces import EXT_CONTINUE, EXT_STOP, EXT_SKIP, PropComparator
-from .deprecated_interfaces import (
-    MapperExtension,
-    SessionExtension,
-    AttributeExtension,
-)
-from .util import (
-    aliased,
-    join,
-    object_mapper,
-    outerjoin,
-    polymorphic_union,
-    was_deleted,
-    with_parent,
-    with_polymorphic,
-)
-from .properties import ColumnProperty
-from .relationships import RelationshipProperty
-from .descriptor_props import (
-    ComparableProperty,
-    CompositeProperty,
-    SynonymProperty,
-)
-from .relationships import foreign, remote
-from .session import (
-    Session,
-    object_session,
-    sessionmaker,
-    make_transient,
-    make_transient_to_detached,
-)
-from .scoping import scoped_session
-from . import mapper as mapperlib
-from .query import AliasOption, Query, Bundle
-from ..util.langhelpers import public_factory
-from .. import util as _sa_util
-from . import strategies as _strategies
+from . import exc  # noqa
+from . import mapper as mapperlib  # noqa
+from . import strategy_options
+from .deprecated_interfaces import AttributeExtension  # noqa
+from .deprecated_interfaces import MapperExtension  # noqa
+from .deprecated_interfaces import SessionExtension  # noqa
+from .descriptor_props import ComparableProperty  # noqa
+from .descriptor_props import CompositeProperty  # noqa
+from .descriptor_props import SynonymProperty  # noqa
+from .interfaces import EXT_CONTINUE  # noqa
+from .interfaces import EXT_SKIP  # noqa
+from .interfaces import EXT_STOP  # noqa
+from .interfaces import PropComparator  # noqa
+from .mapper import _mapper_registry
+from .mapper import class_mapper  # noqa
+from .mapper import configure_mappers  # noqa
+from .mapper import Mapper  # noqa
+from .mapper import reconstructor  # noqa
+from .mapper import validates  # noqa
+from .properties import ColumnProperty  # noqa
+from .query import AliasOption  # noqa
+from .query import Bundle  # noqa
+from .query import Query  # noqa
+from .relationships import foreign  # noqa
+from .relationships import RelationshipProperty  # noqa
+from .relationships import remote  # noqa
+from .scoping import scoped_session  # noqa
+from .session import make_transient  # noqa
+from .session import make_transient_to_detached  # noqa
+from .session import object_session  # noqa
+from .session import Session  # noqa
+from .session import sessionmaker  # noqa
+from .strategy_options import Load  # noqa
+from .util import aliased  # noqa
+from .util import join  # noqa
+from .util import object_mapper  # noqa
+from .util import outerjoin  # noqa
+from .util import polymorphic_union  # noqa
+from .util import was_deleted  # noqa
+from .util import with_parent  # noqa
+from .util import with_polymorphic  # noqa
 from .. import sql as _sql
+from .. import util as _sa_util
+from ..util.langhelpers import public_factory
 
 
 def create_session(bind=None, **kwargs):
@@ -240,8 +237,6 @@ def clear_mappers():
         mapperlib._CONFIGURE_MUTEX.release()
 
 
-from . import strategy_options
-
 joinedload = strategy_options.joinedload._unbound_fn
 joinedload_all = strategy_options.joinedload._unbound_all_fn
 contains_eager = strategy_options.contains_eager._unbound_fn
@@ -262,8 +257,6 @@ raiseload = strategy_options.raiseload._unbound_fn
 defaultload = strategy_options.defaultload._unbound_fn
 selectin_polymorphic = strategy_options.selectin_polymorphic._unbound_fn
 
-from .strategy_options import Load
-
 
 def eagerload(*args, **kwargs):
     """A synonym for :func:`joinedload()`."""
@@ -280,10 +273,10 @@ contains_alias = public_factory(AliasOption, ".orm.contains_alias")
 
 def __go(lcls):
     global __all__
-    from .. import util as sa_util
-    from . import dynamic
-    from . import events
-    from . import loading
+    from .. import util as sa_util  # noqa
+    from . import dynamic  # noqa
+    from . import events  # noqa
+    from . import loading  # noqa
     import inspect as _inspect
 
     __all__ = sorted(
index 1648c9ae10d4b9ab5d0773e2a4557b18091304ce..b5674d010c20d077eef28055f7c28e403f7948bb 100644 (file)
@@ -15,34 +15,38 @@ defines a large part of the ORM's interactivity.
 """
 
 import operator
-from .. import util, event, inspection
-from . import interfaces, collections, exc as orm_exc
-
-from .base import instance_state, instance_dict, manager_of_class
-
-from .base import (
-    PASSIVE_NO_RESULT,
-    ATTR_WAS_SET,
-    ATTR_EMPTY,
-    NO_VALUE,
-    NEVER_SET,
-    NO_CHANGE,
-    CALLABLES_OK,
-    SQL_OK,
-    RELATED_OBJECT_OK,
-    INIT_OK,
-    NON_PERSISTENT_OK,
-    LOAD_AGAINST_COMMITTED,
-    PASSIVE_OFF,
-    PASSIVE_RETURN_NEVER_SET,
-    PASSIVE_NO_INITIALIZE,
-    PASSIVE_NO_FETCH,
-    PASSIVE_NO_FETCH_RELATED,
-    PASSIVE_ONLY_PERSISTENT,
-    NO_AUTOFLUSH,
-    NO_RAISE,
-)
-from .base import state_str, instance_str
+
+from . import collections
+from . import exc as orm_exc
+from . import interfaces
+from .base import ATTR_EMPTY
+from .base import ATTR_WAS_SET
+from .base import CALLABLES_OK
+from .base import INIT_OK
+from .base import instance_dict
+from .base import instance_state
+from .base import instance_str
+from .base import LOAD_AGAINST_COMMITTED
+from .base import manager_of_class
+from .base import NEVER_SET
+from .base import NO_AUTOFLUSH
+from .base import NO_CHANGE  # noqa
+from .base import NO_RAISE
+from .base import NO_VALUE
+from .base import NON_PERSISTENT_OK  # noqa
+from .base import PASSIVE_NO_FETCH
+from .base import PASSIVE_NO_FETCH_RELATED  # noqa
+from .base import PASSIVE_NO_INITIALIZE
+from .base import PASSIVE_NO_RESULT
+from .base import PASSIVE_OFF
+from .base import PASSIVE_ONLY_PERSISTENT
+from .base import PASSIVE_RETURN_NEVER_SET
+from .base import RELATED_OBJECT_OK  # noqa
+from .base import SQL_OK  # noqa
+from .base import state_str
+from .. import event
+from .. import inspection
+from .. import util
 
 
 @inspection._self_inspects
index abc572d9ad751e92b2936c88d2a43295c2d5432b..b90a6ca69b9355b38a5c9f7ce822f94892af34e7 100644 (file)
@@ -9,11 +9,15 @@
 
 """
 
-from .. import util, inspection, exc as sa_exc
-from ..sql import expression
-from . import exc
 import operator
 
+from . import exc
+from .. import exc as sa_exc
+from .. import inspection
+from .. import util
+from ..sql import expression
+
+
 PASSIVE_NO_RESULT = util.symbol(
     "PASSIVE_NO_RESULT",
     """Symbol returned by a loader callable or other attribute/history
index be92917415d6f17e1a9c3f7e9dc96e0cf4d1edff..2454f9fae1dd4f402aff1d30efb1c5000bc91738 100644 (file)
@@ -103,15 +103,15 @@ through the adapter, allowing for some very sophisticated behavior.
 
 """
 
-import inspect
 import operator
 import weakref
 
-from ..sql import expression
-from .. import util, exc as sa_exc
+from sqlalchemy.util.compat import inspect_getargspec
 from . import base
+from .. import exc as sa_exc
+from .. import util
+from ..sql import expression
 
-from sqlalchemy.util.compat import inspect_getargspec
 
 __all__ = [
     "collection",
index cba4d2141a33626f6c73b40e16bb7e3d4e3e0258..ed3653de53ab684a07c1208246528c88c2313063 100644 (file)
@@ -9,9 +9,17 @@
 
 """
 
-from .. import sql, util, exc as sa_exc
-from . import attributes, exc, sync, unitofwork, util as mapperutil
-from .interfaces import ONETOMANY, MANYTOONE, MANYTOMANY
+from . import attributes
+from . import exc
+from . import sync
+from . import unitofwork
+from . import util as mapperutil
+from .interfaces import MANYTOMANY
+from .interfaces import MANYTOONE
+from .interfaces import ONETOMANY
+from .. import exc as sa_exc
+from .. import sql
+from .. import util
 
 
 class DependencyProcessor(object):
@@ -1180,9 +1188,9 @@ class ManyToManyDP(DependencyProcessor):
             )
             result = connection.execute(statement, secondary_delete)
 
-            if result.supports_sane_multi_rowcount() and result.rowcount != len(
-                secondary_delete
-            ):
+            if (
+                result.supports_sane_multi_rowcount()
+            ) and result.rowcount != len(secondary_delete):
                 raise exc.StaleDataError(
                     "DELETE statement on table '%s' expected to delete "
                     "%d row(s); Only %d were matched."
@@ -1206,9 +1214,9 @@ class ManyToManyDP(DependencyProcessor):
             )
             result = connection.execute(statement, secondary_update)
 
-            if result.supports_sane_multi_rowcount() and result.rowcount != len(
-                secondary_update
-            ):
+            if (
+                result.supports_sane_multi_rowcount()
+            ) and result.rowcount != len(secondary_update):
                 raise exc.StaleDataError(
                     "UPDATE statement on table '%s' expected to update "
                     "%d row(s); Only %d were matched."
index 6b51404d0c0f5d044d7c18358705e2bb28dd79e5..0b99ce85d056e3d4328d51015acb5fdf37090e9e 100644 (file)
@@ -5,8 +5,9 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from .. import event, util
 from .interfaces import EXT_CONTINUE
+from .. import event
+from .. import util
 
 
 @util.langhelpers.dependency_for("sqlalchemy.orm.interfaces")
index 37517e84c95de08846b1d251a295804966163fb4..0891a2a9d5351f2802ba8caf7bbae8ee086f0dec 100644 (file)
@@ -11,13 +11,18 @@ as actively in the load/persist ORM loop.
 
 """
 
-from .interfaces import MapperProperty, PropComparator
-from .util import _none_set
 from . import attributes
-from .. import util, sql, exc as sa_exc, event, schema
-from ..sql import expression
 from . import properties
 from . import query
+from .interfaces import MapperProperty
+from .interfaces import PropComparator
+from .util import _none_set
+from .. import event
+from .. import exc as sa_exc
+from .. import schema
+from .. import sql
+from .. import util
+from ..sql import expression
 
 
 class DescriptorProperty(MapperProperty):
@@ -366,10 +371,10 @@ class CompositeProperty(DescriptorProperty):
         return self.comparator_factory(self, mapper)
 
     class CompositeBundle(query.Bundle):
-        def __init__(self, property, expr):
-            self.property = property
+        def __init__(self, property_, expr):
+            self.property = property_
             super(CompositeProperty.CompositeBundle, self).__init__(
-                property.key, *expr
+                property_.key, *expr
             )
 
         def create_row_processor(self, query, procs, labels):
index e5c6b80b66ce3788212dad416d906fbe3c2352b6..9665e248564e028d0a1b431e5a2b8d3a5eb399a3 100644 (file)
@@ -12,18 +12,17 @@ basic add/delete mutation.
 
 """
 
-from .. import log, util, exc
-from ..sql import operators
-from . import (
-    attributes,
-    object_session,
-    util as orm_util,
-    strategies,
-    object_mapper,
-    exc as orm_exc,
-    properties,
-)
+from . import attributes
+from . import exc as orm_exc
+from . import object_mapper
+from . import object_session
+from . import properties
+from . import strategies
+from . import util as orm_util
 from .query import Query
+from .. import exc
+from .. import log
+from .. import util
 
 
 @log.class_logger
index ac031d84f5e38bde544bf36071bd546fa8805b54..2de59074854b30411e2dee3566e2fbab35d985e0 100644 (file)
@@ -6,9 +6,10 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 import operator
-from ..sql import operators
+
 from .. import inspect
 from .. import util
+from ..sql import operators
 
 
 class UnevaluatableError(Exception):
index c2a2d15ee30b99d5891213ce8418aed7d640c2c0..7c4cfc3bab92fd7b56d738b4ceade06670920501 100644 (file)
@@ -8,17 +8,21 @@
 """ORM event interfaces.
 
 """
-from .. import event, exc, util
-from .base import _mapper_or_none
-import inspect
 import weakref
+
+from . import instrumentation
 from . import interfaces
-from . import mapperlib, instrumentation
-from .session import Session, sessionmaker
-from .scoping import scoped_session
+from . import mapperlib
 from .attributes import QueryableAttribute
+from .base import _mapper_or_none
 from .query import Query
-from sqlalchemy.util.compat import inspect_getargspec
+from .scoping import scoped_session
+from .session import Session
+from .session import sessionmaker
+from .. import event
+from .. import exc
+from .. import util
+from ..util.compat import inspect_getargspec
 
 
 class InstrumentationEvents(event.Events):
@@ -1885,7 +1889,7 @@ class SessionEvents(event.Events):
 
 
 class AttributeEvents(event.Events):
-    """Define events for object attributes.
+    r"""Define events for object attributes.
 
     These are typically defined on the class-bound descriptor for the
     target class.
index f0aa02e99e0ff87480a00a66f92d4b8f62ad9806..a8dcf2642f2ed1ab9e3e227cc969cff632a16d87 100644 (file)
@@ -6,7 +6,9 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 """SQLAlchemy ORM exceptions."""
-from .. import exc as sa_exc, util
+from .. import exc as sa_exc
+from .. import util
+
 
 NO_STATE = (AttributeError, KeyError)
 """Exception types that may be raised by instrumentation implementations."""
index 2487cdb233e099c23eef4604117f861fa94bca16..8152c9884ff40f8d716724e88eba67d545be2c11 100644 (file)
@@ -6,10 +6,11 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 import weakref
+
 from . import attributes
-from .. import util
-from .. import exc as sa_exc
 from . import util as orm_util
+from .. import exc as sa_exc
+from .. import util
 
 
 class IdentityMap(object):
@@ -32,7 +33,7 @@ class IdentityMap(object):
         in the map"""
         self.add(state)
 
-    def update(self, dict):
+    def update(self, dict_):
         raise NotImplementedError("IdentityMap uses add() to insert data")
 
     def clear(self):
index fa29c32333a604d5a7649f95359f430d38e2bece..a0fe2535722941521fcb636c59a5fb045091121d 100644 (file)
@@ -30,9 +30,12 @@ alternate instrumentation forms.
 """
 
 
-from . import exc, collections, interfaces, state
-from .. import util
 from . import base
+from . import collections
+from . import exc
+from . import interfaces
+from . import state
+from .. import util
 
 
 _memoized_key_collection = util.group_expirable_memoized_property()
@@ -69,8 +72,8 @@ class ClassManager(dict):
             if mgr is not None
         ]
 
-        for base in self._bases:
-            self.update(base)
+        for base_ in self._bases:
+            self.update(base_)
 
         self.dispatch._events._new_classmanager_instance(class_, self)
         # events._InstanceEventsHold.populate(class_, self)
index d7e70c5d740b062459575ea1e4981d739c4f6b3a..5df310db2932fdf6e2b82b2fb97c6a8b5f6ab5c3 100644 (file)
@@ -20,21 +20,23 @@ are exposed when inspecting mappings.
 
 from __future__ import absolute_import
 
-from .. import util
-from ..sql import operators
-from .base import (
-    ONETOMANY,
-    MANYTOONE,
-    MANYTOMANY,
-    EXT_CONTINUE,
-    EXT_STOP,
-    EXT_SKIP,
-    NOT_EXTENSION,
-)
-from .base import InspectionAttr, InspectionAttrInfo, _MappedAttribute
 import collections
-from .. import inspect
+
 from . import path_registry
+from .base import _MappedAttribute  # noqa
+from .base import EXT_CONTINUE
+from .base import EXT_SKIP
+from .base import EXT_STOP
+from .base import InspectionAttr  # noqa
+from .base import InspectionAttrInfo  # noqa
+from .base import MANYTOMANY
+from .base import MANYTOONE
+from .base import NOT_EXTENSION
+from .base import ONETOMANY
+from .. import inspect
+from .. import util
+from ..sql import operators
+
 
 # imported later
 MapperExtension = SessionExtension = AttributeExtension = None
index 96eddcb326cf4b3040a37c9f864c35ac18a23048..3662bbe513352eb141561a89f82f1e48a4aedd20 100644 (file)
@@ -14,17 +14,20 @@ as well as some of the attribute loading strategies.
 """
 from __future__ import absolute_import
 
+import collections
+
+from . import attributes
+from . import exc as orm_exc
+from . import path_registry
+from . import strategy_options
+from .base import _DEFER_FOR_STATE
+from .base import _SET_DEFERRED_EXPIRED
+from .util import _none_set
+from .util import state_str
+from .. import exc as sa_exc
 from .. import util
-from . import attributes, exc as orm_exc
 from ..sql import util as sql_util
-from . import strategy_options
-from . import path_registry
-from .. import sql
 
-from .util import _none_set, state_str
-from .base import _SET_DEFERRED_EXPIRED, _DEFER_FOR_STATE
-from .. import exc as sa_exc
-import collections
 
 _new_runid = util.counter()
 
index ea88907889c6e03d406926427f55ff628197af92..c0a53694a2189c1e8fe8ee0a7b7b8b43643bed82 100644 (file)
@@ -16,34 +16,39 @@ available in :class:`~sqlalchemy.orm.`.
 """
 from __future__ import absolute_import
 
+from collections import deque
+from itertools import chain
+import sys
 import types
 import weakref
-from itertools import chain
-from collections import deque
 
-from .. import sql, util, log, exc as sa_exc, event, schema, inspection
-from ..sql import expression, visitors, operators, util as sql_util
-from . import instrumentation, attributes, exc as orm_exc, loading
+from . import attributes
+from . import exc as orm_exc
+from . import instrumentation
+from . import loading
 from . import properties
 from . import util as orm_util
-from .interfaces import (
-    MapperProperty,
-    InspectionAttr,
-    _MappedAttribute,
-    EXT_SKIP,
-)
-
-
-from .base import (
-    _class_to_mapper,
-    _state_mapper,
-    class_mapper,
-    state_str,
-    _INSTRUMENTOR,
-)
+from .base import _class_to_mapper
+from .base import _INSTRUMENTOR
+from .base import _state_mapper
+from .base import class_mapper
+from .base import state_str
+from .interfaces import _MappedAttribute
+from .interfaces import EXT_SKIP
+from .interfaces import InspectionAttr
+from .interfaces import MapperProperty
 from .path_registry import PathRegistry
-
-import sys
+from .. import event
+from .. import exc as sa_exc
+from .. import inspection
+from .. import log
+from .. import schema
+from .. import sql
+from .. import util
+from ..sql import expression
+from ..sql import operators
+from ..sql import util as sql_util
+from ..sql import visitors
 
 
 _mapper_registry = weakref.WeakKeyDictionary()
@@ -1087,7 +1092,7 @@ class Mapper(InspectionAttr):
                 self.polymorphic_map[self.polymorphic_identity] = self
 
             if self.polymorphic_load and self.concrete:
-                raise exc.ArgumentError(
+                raise sa_exc.ArgumentError(
                     "polymorphic_load is not currently supported "
                     "with concrete table inheritance"
                 )
@@ -1615,9 +1620,9 @@ class Mapper(InspectionAttr):
                     if self.mapped_table is mapper.mapped_table:
                         self.polymorphic_on = mapper.polymorphic_on
                     else:
-                        self.polymorphic_on = self.mapped_table.corresponding_column(
-                            mapper.polymorphic_on
-                        )
+                        self.polymorphic_on = (
+                            self.mapped_table.corresponding_column
+                        )(mapper.polymorphic_on)
                     # we can use the parent mapper's _set_polymorphic_identity
                     # directly; it ensures the polymorphic_identity of the
                     # instance's mapper is used so is portable to subclasses.
@@ -2485,7 +2490,7 @@ class Mapper(InspectionAttr):
 
     @_memoized_configured_property
     def _equivalent_columns(self):
-        """Create a map of all *equivalent* columns, based on
+        """Create a map of all equivalent columns, based on
         the determination of column pairs that are equated to
         one another based on inherit condition.  This is designed
         to work with the queries that util.polymorphic_union
@@ -2494,14 +2499,14 @@ class Mapper(InspectionAttr):
         only).
 
         The resulting structure is a dictionary of columns mapped
-        to lists of equivalent columns, i.e.
+        to lists of equivalent columns, e.g.::
 
-        {
-            tablea.col1:
-                {tableb.col1, tablec.col1},
-            tablea.col2:
-                {tabled.col2}
-        }
+            {
+                tablea.col1:
+                    {tableb.col1, tablec.col1},
+                tablea.col2:
+                    {tabled.col2}
+            }
 
         """
         result = util.column_dict()
@@ -3026,10 +3031,18 @@ class Mapper(InspectionAttr):
                 if queue:
                     visitables.append((queue, mpp, None, None))
             elif item_type is mpp:
-                instance, instance_mapper, corresponding_state, corresponding_dict = (
-                    iterator.popleft()
+                (
+                    instance,
+                    instance_mapper,
+                    corresponding_state,
+                    corresponding_dict,
+                ) = iterator.popleft()
+                yield (
+                    instance,
+                    instance_mapper,
+                    corresponding_state,
+                    corresponding_dict,
                 )
-                yield instance, instance_mapper, corresponding_state, corresponding_dict
                 visitables.append(
                     (
                         deque(instance_mapper._props.values()),
index f33c209cc7b4366d829e0ddbb333c50de8d5e881..97f15d9f6431d7900486278e80f7add11f9c465d 100644 (file)
@@ -8,13 +8,15 @@
 
 """
 
-from .. import inspection
-from .. import util
-from .. import exc
 from itertools import chain
-from .base import class_mapper
 import logging
 
+from .base import class_mapper
+from .. import exc
+from .. import inspection
+from .. import util
+
+
 log = logging.getLogger(__name__)
 
 
index dc86a60e5460b8e1ff2467babd8fcd6e0cae480e..9e96cda42752217c021ef88668f60a915e1f0737 100644 (file)
@@ -14,14 +14,22 @@ in unitofwork.py.
 
 """
 
+from itertools import chain
+from itertools import groupby
 import operator
-from itertools import groupby, chain
-from .. import sql, util, exc as sa_exc
-from . import attributes, sync, exc as orm_exc, evaluator
-from .base import state_str, _entity_descriptor
+
+from . import attributes
+from . import evaluator
+from . import exc as orm_exc
+from . import loading
+from . import sync
+from .base import _entity_descriptor
+from .base import state_str
+from .. import exc as sa_exc
+from .. import sql
+from .. import util
 from ..sql import expression
 from ..sql.base import _from_objects
-from . import loading
 
 
 def _bulk_insert(
@@ -67,7 +75,16 @@ def _bulk_insert(
                 has_all_pks,
                 has_all_defaults,
             )
-            for state, state_dict, params, mp, conn, value_params, has_all_pks, has_all_defaults in _collect_insert_commands(
+            for (
+                state,
+                state_dict,
+                params,
+                mp,
+                conn,
+                value_params,
+                has_all_pks,
+                has_all_defaults,
+            ) in _collect_insert_commands(
                 table,
                 ((None, mapping, mapper, connection) for mapping in mappings),
                 bulk=True,
@@ -234,11 +251,17 @@ def save_obj(base_mapper, states, uowtransaction, single=False):
         chain(
             (
                 (state, state_dict, mapper, connection, False)
-                for state, state_dict, mapper, connection in states_to_insert
+                for (state, state_dict, mapper, connection) in states_to_insert
             ),
             (
                 (state, state_dict, mapper, connection, True)
-                for state, state_dict, mapper, connection, update_version_id in states_to_update
+                for (
+                    state,
+                    state_dict,
+                    mapper,
+                    connection,
+                    update_version_id,
+                ) in states_to_update
             ),
         ),
     )
@@ -609,9 +632,9 @@ def _collect_update_commands(
                     params[col.key] = value
 
             if mapper.base_mapper.eager_defaults:
-                has_all_defaults = mapper._server_onupdate_default_cols[
-                    table
-                ].issubset(params)
+                has_all_defaults = (
+                    mapper._server_onupdate_default_cols[table]
+                ).issubset(params)
             else:
                 has_all_defaults = True
 
index a39cd87036fd18fd46e19df2bbe1e4b56b4ed2a4..3ea68a913e903ca6df55b6f094b0144c7f972bcd 100644 (file)
@@ -13,12 +13,14 @@ mapped attributes.
 """
 from __future__ import absolute_import
 
-from .. import util, log
-from ..sql import expression
 from . import attributes
+from .interfaces import PropComparator
+from .interfaces import StrategizedProperty
 from .util import _orm_full_deannotate
+from .. import log
+from .. import util
+from ..sql import expression
 
-from .interfaces import PropComparator, StrategizedProperty
 
 __all__ = ["ColumnProperty"]
 
@@ -213,9 +215,9 @@ class ColumnProperty(StrategizedProperty):
             util.warn(
                 (
                     "On mapper %s, primary key column '%s' is being combined "
-                    "with distinct primary key column '%s' in attribute '%s'.  "
-                    "Use explicit properties to give each column its own mapped "
-                    "attribute name."
+                    "with distinct primary key column '%s' in attribute '%s'. "
+                    "Use explicit properties to give each column its own "
+                    "mapped attribute name."
                 )
                 % (self.parent, self.columns[1], self.columns[0], self.key)
             )
index 4a55a324785d6f9404f37c40b06217f54e1eeb1b..a4dddcd239397949058937837eea4c9a2c627ec1 100644 (file)
@@ -21,36 +21,39 @@ database to return iterable result sets.
 
 from itertools import chain
 
-from . import (
-    attributes,
-    interfaces,
-    object_mapper,
-    persistence,
-    exc as orm_exc,
-    loading,
-)
-from .base import (
-    _entity_descriptor,
-    _is_aliased_class,
-    _is_mapped_class,
-    _orm_columns,
-    _generative,
-    InspectionAttr,
-)
+from . import attributes
+from . import exc as orm_exc
+from . import interfaces
+from . import loading
+from . import persistence
+from . import properties
+from .base import _entity_descriptor
+from .base import _generative
+from .base import _is_aliased_class
+from .base import _is_mapped_class
+from .base import _orm_columns
+from .base import InspectionAttr
 from .path_registry import PathRegistry
-from .util import (
-    AliasedClass,
-    ORMAdapter,
-    join as orm_join,
-    with_parent,
-    aliased,
-    _entity_corresponds_to,
-)
-from .. import sql, util, log, exc as sa_exc, inspect, inspection
-from ..sql.expression import _interpret_as_from
-from ..sql import util as sql_util, expression, visitors
+from .util import _entity_corresponds_to
+from .util import aliased
+from .util import AliasedClass
+from .util import join as orm_join
+from .util import object_mapper
+from .util import ORMAdapter
+from .util import with_parent
+from .. import exc as sa_exc
+from .. import inspect
+from .. import inspection
+from .. import log
+from .. import sql
+from .. import util
+from ..sql import expression
+from ..sql import util as sql_util
+from ..sql import visitors
 from ..sql.base import ColumnCollection
-from . import properties
+from ..sql.expression import _interpret_as_from
+from ..sql.selectable import ForUpdateArg
+
 
 __all__ = ["Query", "QueryContext", "aliased"]
 
@@ -1103,7 +1106,7 @@ class Query(object):
         """
         self._invoke_all_eagers = value
 
-    def with_parent(self, instance, property=None, from_entity=None):
+    def with_parent(self, instance, property=None, from_entity=None):  # noqa
         """Add filtering criterion that relates the given instance
         to a child object or collection, using its attribute state
         as well as an established :func:`.relationship()`
@@ -1143,7 +1146,7 @@ class Query(object):
                     isinstance(prop, properties.RelationshipProperty)
                     and prop.mapper is entity_zero.mapper
                 ):
-                    property = prop
+                    property = prop  # noqa
                     break
             else:
                 raise sa_exc.InvalidRequestError(
@@ -2397,17 +2400,20 @@ class Query(object):
             # figure out the best "left" side based on our existing froms /
             # entities
             assert prop is None
-            left, replace_from_obj_index, use_entity_index = self._join_determine_implicit_left_side(
-                left, right, onclause
-            )
+            (
+                left,
+                replace_from_obj_index,
+                use_entity_index,
+            ) = self._join_determine_implicit_left_side(left, right, onclause)
         else:
             # left is given via a relationship/name.  Determine where in our
             # "froms" list it should be spliced/appended as well as what
             # existing entity it corresponds to.
             assert prop is not None
-            replace_from_obj_index, use_entity_index = self._join_place_explicit_left_side(
-                left
-            )
+            (
+                replace_from_obj_index,
+                use_entity_index,
+            ) = self._join_place_explicit_left_side(left)
 
         # this should never happen because we would not have found a place
         # to join on
@@ -3153,7 +3159,8 @@ class Query(object):
         (note this may consist of multiple result rows if join-loaded
         collections are present).
 
-        Calling :meth:`.Query.first` results in an execution of the underlying query.
+        Calling :meth:`.Query.first` results in an execution of the underlying
+        query.
 
         .. seealso::
 
@@ -3665,7 +3672,8 @@ class Query(object):
          values or sql expressions as values.   If :ref:`parameter-ordered
          mode <updates_order_parameters>` is desired, the values can be
          passed as a list of 2-tuples;
-         this requires that the :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`
+         this requires that the
+         :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`
          flag is passed to the :paramref:`.Query.update.update_args` dictionary
          as well.
 
@@ -3905,9 +3913,9 @@ class Query(object):
             context.order_by = None
 
         if self._distinct is True and context.order_by:
-            context.primary_columns += sql_util.expand_column_list_from_order_by(
-                context.primary_columns, context.order_by
-            )
+            context.primary_columns += (
+                sql_util.expand_column_list_from_order_by
+            )(context.primary_columns, context.order_by)
         context.froms += tuple(context.eager_joins.values())
 
         statement = sql.select(
@@ -3966,9 +3974,6 @@ class Query(object):
                 )
 
 
-from ..sql.selectable import ForUpdateArg
-
-
 class LockmodeArg(ForUpdateArg):
     @classmethod
     def parse_legacy_query(self, mode):
index e89d1542fa6136b988386c5a07f4043281e2b052..27a8c4ca98644c86886465ad6e27f445a279c4d9 100644 (file)
@@ -14,34 +14,38 @@ and `secondaryjoin` aspects of :func:`.relationship`.
 
 """
 from __future__ import absolute_import
-from .. import sql, util, exc as sa_exc, schema, log
 
+import collections
 import weakref
-from .util import CascadeOptions, _orm_annotate, _orm_deannotate
-from . import dependency
+
 from . import attributes
-from ..sql.util import (
-    ClauseAdapter,
-    join_condition,
-    _shallow_annotate,
-    visit_binary_product,
-    _deep_deannotate,
-    selectables_overlap,
-    adapt_criterion_to_null,
-)
+from . import dependency
+from . import mapper as mapperlib
 from .base import state_str
-
-from ..sql import operators, expression, visitors
-from .interfaces import (
-    MANYTOMANY,
-    MANYTOONE,
-    ONETOMANY,
-    StrategizedProperty,
-    PropComparator,
-)
+from .interfaces import MANYTOMANY
+from .interfaces import MANYTOONE
+from .interfaces import ONETOMANY
+from .interfaces import PropComparator
+from .interfaces import StrategizedProperty
+from .util import _orm_annotate
+from .util import _orm_deannotate
+from .util import CascadeOptions
+from .. import exc as sa_exc
+from .. import log
+from .. import schema
+from .. import sql
+from .. import util
 from ..inspection import inspect
-from . import mapper as mapperlib
-import collections
+from ..sql import expression
+from ..sql import operators
+from ..sql import visitors
+from ..sql.util import _deep_deannotate
+from ..sql.util import _shallow_annotate
+from ..sql.util import adapt_criterion_to_null
+from ..sql.util import ClauseAdapter
+from ..sql.util import join_condition
+from ..sql.util import selectables_overlap
+from ..sql.util import visit_binary_product
 
 
 def remote(expr):
@@ -88,7 +92,7 @@ def foreign(expr):
 
 
 @log.class_logger
-@util.langhelpers.dependency_for("sqlalchemy.orm.properties")
+@util.langhelpers.dependency_for("sqlalchemy.orm.properties", add_to_all=True)
 class RelationshipProperty(StrategizedProperty):
     """Describes an object property that holds a single item or list
     of items that correspond to a related database table.
@@ -596,8 +600,8 @@ class RelationshipProperty(StrategizedProperty):
 
           .. seealso::
 
-            :doc:`/orm/loading_relationships` - Full documentation on relationship loader
-            configuration.
+            :doc:`/orm/loading_relationships` - Full documentation on
+            relationship loader configuration.
 
             :ref:`dynamic_relationship` - detail on the ``dynamic`` option.
 
@@ -991,7 +995,14 @@ class RelationshipProperty(StrategizedProperty):
             else:
                 of_type = None
 
-            pj, sj, source, dest, secondary, target_adapter = self.property._create_joins(
+            (
+                pj,
+                sj,
+                source,
+                dest,
+                secondary,
+                target_adapter,
+            ) = self.property._create_joins(
                 source_selectable=adapt_from,
                 source_polymorphic=True,
                 of_type=of_type,
@@ -1112,7 +1123,14 @@ class RelationshipProperty(StrategizedProperty):
             else:
                 source_selectable = None
 
-            pj, sj, source, dest, secondary, target_adapter = self.property._create_joins(
+            (
+                pj,
+                sj,
+                source,
+                dest,
+                secondary,
+                target_adapter,
+            ) = self.property._create_joins(
                 dest_polymorphic=True,
                 dest_selectable=to_selectable,
                 source_selectable=source_selectable,
@@ -1508,7 +1526,7 @@ class RelationshipProperty(StrategizedProperty):
 
         Above, the SQL should be "address.user_id = 5". The callable
         returned by this method produces the value "5" based on the identity
-        of ``u1`.
+        of ``u1``.
 
         """
 
@@ -2108,9 +2126,9 @@ class RelationshipProperty(StrategizedProperty):
         if self.uselist is None:
             self.uselist = self.direction is not MANYTOONE
         if not self.viewonly:
-            self._dependency_processor = dependency.DependencyProcessor.from_relationship(
-                self
-            )
+            self._dependency_processor = (
+                dependency.DependencyProcessor.from_relationship
+            )(self)
 
     @util.memoized_property
     def _use_get(self):
@@ -2155,7 +2173,13 @@ class RelationshipProperty(StrategizedProperty):
         single_crit = dest_mapper._single_table_criterion
         aliased = aliased or (source_selectable is not None)
 
-        primaryjoin, secondaryjoin, secondary, target_adapter, dest_selectable = self._join_condition.join_targets(
+        (
+            primaryjoin,
+            secondaryjoin,
+            secondary,
+            target_adapter,
+            dest_selectable,
+        ) = self._join_condition.join_targets(
             source_selectable, dest_selectable, aliased, single_crit
         )
         if source_selectable is None:
index 2eeaf5b6d3c435e5a7806cd795aaf742c2cbe4e3..fea0b1de86d01675b265016f18006a7fc6e5dd37 100644 (file)
@@ -5,10 +5,13 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from .. import exc as sa_exc
-from ..util import ScopedRegistry, ThreadLocalRegistry, warn
-from . import class_mapper, exc as orm_exc
+from . import class_mapper
+from . import exc as orm_exc
 from .session import Session
+from .. import exc as sa_exc
+from ..util import ScopedRegistry
+from ..util import ThreadLocalRegistry
+from ..util import warn
 
 
 __all__ = ["scoped_session"]
@@ -166,13 +169,13 @@ for meth in Session.public_methods:
 
 
 def makeprop(name):
-    def set(self, attr):
+    def set_(self, attr):
         setattr(self.registry(), name, attr)
 
     def get(self):
         return getattr(self.registry(), name)
 
-    return property(get, set)
+    return property(get, set_)
 
 
 for prop in (
index a3edacc194d3af64941d464c6ee854fd37c2c82b..d226edf817360e43081e0926e3a8a11bbe96a147 100644 (file)
@@ -7,26 +7,34 @@
 """Provides the Session class and related utilities."""
 
 
-import weakref
-from .. import util, sql, engine, exc as sa_exc
-from ..sql import util as sql_util, expression
-from . import SessionExtension, attributes, exc, query, loading, identity
-from ..inspection import inspect
-from .base import (
-    object_mapper,
-    class_mapper,
-    _class_to_mapper,
-    _state_mapper,
-    object_state,
-    _none_set,
-    state_str,
-    instance_str,
-)
 import itertools
+import sys
+import weakref
+
+from . import attributes
+from . import exc
+from . import identity
+from . import loading
 from . import persistence
-from .unitofwork import UOWTransaction
+from . import query
 from . import state as statelib
-import sys
+from .base import _class_to_mapper
+from .base import _none_set
+from .base import _state_mapper
+from .base import instance_str
+from .base import object_mapper
+from .base import object_state
+from .base import state_str
+from .deprecated_interfaces import SessionExtension
+from .unitofwork import UOWTransaction
+from .. import engine
+from .. import exc as sa_exc
+from .. import sql
+from .. import util
+from ..inspection import inspect
+from ..sql import expression
+from ..sql import util as sql_util
+
 
 __all__ = ["Session", "SessionTransaction", "SessionExtension", "sessionmaker"]
 
@@ -578,11 +586,11 @@ class SessionTransaction(object):
     def __enter__(self):
         return self
 
-    def __exit__(self, type, value, traceback):
+    def __exit__(self, type_, value, traceback):
         self._assert_active(deactive_ok=True, prepared_ok=True)
         if self.session.transaction is None:
             return
-        if type is None:
+        if type_ is None:
             try:
                 self.commit()
             except:
@@ -888,9 +896,10 @@ class Session(_SessionClassMethods):
         :param subtransactions: if True, indicates that this
          :meth:`~.Session.begin` can create a "subtransaction".
 
-        :param nested: if True, begins a SAVEPOINT transaction and is equivalent
-         to calling :meth:`~.Session.begin_nested`. For documentation on
-         SAVEPOINT transactions, please see :ref:`session_begin_nested`.
+        :param nested: if True, begins a SAVEPOINT transaction and is
+         equivalent to calling :meth:`~.Session.begin_nested`. For
+         documentation on SAVEPOINT transactions, please see
+         :ref:`session_begin_nested`.
 
         :return: the :class:`.SessionTransaction` object.  Note that
          :class:`.SessionTransaction`
index c36d8817b8278fe7be968f6408bba3295d6545bd..6e539a3beadf02cca1a00663bc3b9ed225fdf114 100644 (file)
@@ -13,22 +13,22 @@ defines a large part of the ORM's interactivity.
 """
 
 import weakref
-from .. import util
-from .. import inspection
-from .. import exc as sa_exc
-from . import exc as orm_exc, interfaces
-from .path_registry import PathRegistry
-from .base import (
-    PASSIVE_NO_RESULT,
-    SQL_OK,
-    NEVER_SET,
-    ATTR_WAS_SET,
-    NO_VALUE,
-    PASSIVE_NO_INITIALIZE,
-    INIT_OK,
-    PASSIVE_OFF,
-)
+
 from . import base
+from . import exc as orm_exc
+from . import interfaces
+from .base import ATTR_WAS_SET
+from .base import INIT_OK
+from .base import NEVER_SET
+from .base import NO_VALUE
+from .base import PASSIVE_NO_INITIALIZE
+from .base import PASSIVE_NO_RESULT
+from .base import PASSIVE_OFF
+from .base import SQL_OK
+from .path_registry import PathRegistry
+from .. import exc as sa_exc
+from .. import inspection
+from .. import util
 
 
 @inspection._self_inspects
@@ -157,8 +157,9 @@ class InstanceState(interfaces.InspectionAttrInfo):
             "detached" states; once the object is :term:`detached`, the
             :attr:`.InstanceState.deleted` attribute **no longer returns
             True**; in order to detect that a state was deleted, regardless
-            of whether or not the object is associated with a :class:`.Session`,
-            use the :attr:`.InstanceState.was_deleted` accessor.
+            of whether or not the object is associated with a
+            :class:`.Session`, use the :attr:`.InstanceState.was_deleted`
+            accessor.
 
         .. versionadded: 1.1
 
@@ -815,10 +816,10 @@ class InstanceState(interfaces.InspectionAttrInfo):
         self._commit_all_states([(self, dict_)], instance_dict)
 
     @classmethod
-    def _commit_all_states(self, iter, instance_dict=None):
+    def _commit_all_states(self, iter_, instance_dict=None):
         """Mass / highly inlined version of commit_all()."""
 
-        for state, dict_ in iter:
+        for state, dict_ in iter_:
             state_dict = state.__dict__
 
             state.committed_state.clear()
index 5c972b26b8b4837b39f4afaaa493956c3af54b5e..afa91d876362004690b218aa6a592798ad643d99 100644 (file)
@@ -8,26 +8,32 @@
 """sqlalchemy.orm.interfaces.LoaderStrategy
    implementations, and related MapperOptions."""
 
-from .. import exc as sa_exc, inspect
-from .. import util, log, event
-from ..sql import util as sql_util, visitors
-from .. import sql
-from . import (
-    attributes,
-    interfaces,
-    exc as orm_exc,
-    loading,
-    unitofwork,
-    util as orm_util,
-    query,
-)
-from .state import InstanceState
-from .util import _none_set, aliased
+import itertools
+
+from . import attributes
+from . import exc as orm_exc
+from . import interfaces
+from . import loading
 from . import properties
-from .interfaces import LoaderStrategy, StrategizedProperty
-from .base import _SET_DEFERRED_EXPIRED, _DEFER_FOR_STATE
+from . import query
+from . import unitofwork
+from . import util as orm_util
+from .base import _DEFER_FOR_STATE
+from .base import _SET_DEFERRED_EXPIRED
+from .interfaces import LoaderStrategy
+from .interfaces import StrategizedProperty
 from .session import _state_session
-import itertools
+from .state import InstanceState
+from .util import _none_set
+from .util import aliased
+from .. import event
+from .. import exc as sa_exc
+from .. import inspect
+from .. import log
+from .. import sql
+from .. import util
+from ..sql import util as sql_util
+from ..sql import visitors
 
 
 def _register_attribute(
@@ -524,9 +530,11 @@ class LazyLoader(AbstractRelationshipLoader, util.MemoizedSlots):
             join_condition.create_lazy_clause()
         )
 
-        self._rev_lazywhere, self._rev_bind_to_col, self._rev_equated_columns = join_condition.create_lazy_clause(
-            reverse_direction=True
-        )
+        (
+            self._rev_lazywhere,
+            self._rev_bind_to_col,
+            self._rev_equated_columns,
+        ) = join_condition.create_lazy_clause(reverse_direction=True)
 
         self.logger.info("%s lazy loading clause %s", self, self._lazywhere)
 
@@ -875,9 +883,9 @@ class LazyLoader(AbstractRelationshipLoader, util.MemoizedSlots):
             # "lazyload" option on a "no load"
             # attribute - "eager" attributes always have a
             # class-level lazyloader installed.
-            set_lazy_callable = InstanceState._instance_level_callable_processor(
-                mapper.class_manager, LoadLazyAttribute(key, self), key
-            )
+            set_lazy_callable = (
+                InstanceState._instance_level_callable_processor
+            )(mapper.class_manager, LoadLazyAttribute(key, self), key)
 
             populators["new"].append((self.key, set_lazy_callable))
         elif context.populate_existing or mapper.always_refresh:
@@ -1008,9 +1016,11 @@ class SubqueryLoader(AbstractRelationshipLoader):
             elif subq_path.contains_mapper(self.mapper):
                 return
 
-        leftmost_mapper, leftmost_attr, leftmost_relationship = self._get_leftmost(
-            subq_path
-        )
+        (
+            leftmost_mapper,
+            leftmost_attr,
+            leftmost_relationship,
+        ) = self._get_leftmost(subq_path)
 
         orig_query = context.attributes.get(
             ("orig_query", SubqueryLoader), context.query
@@ -1439,7 +1449,11 @@ class JoinedLoader(AbstractRelationshipLoader):
         )
 
         if user_defined_adapter is not False:
-            clauses, adapter, add_to_collection = self._setup_query_on_user_defined_adapter(
+            (
+                clauses,
+                adapter,
+                add_to_collection,
+            ) = self._setup_query_on_user_defined_adapter(
                 context, entity, path, adapter, user_defined_adapter
             )
         else:
@@ -1452,7 +1466,12 @@ class JoinedLoader(AbstractRelationshipLoader):
                 elif path.contains_mapper(self.mapper):
                     return
 
-            clauses, adapter, add_to_collection, chained_from_outerjoin = self._generate_row_adapter(
+            (
+                clauses,
+                adapter,
+                add_to_collection,
+                chained_from_outerjoin,
+            ) = self._generate_row_adapter(
                 context,
                 entity,
                 path,
@@ -1795,9 +1814,9 @@ class JoinedLoader(AbstractRelationshipLoader):
                     context.primary_columns.append(col)
 
         if self.parent_property.order_by:
-            context.eager_order_by += eagerjoin._target_adapter.copy_and_process(
-                util.to_list(self.parent_property.order_by)
-            )
+            context.eager_order_by += (
+                eagerjoin._target_adapter.copy_and_process
+            )(util.to_list(self.parent_property.order_by))
 
     def _splice_nested_inner_join(
         self, path, join_obj, clauses, onclause, splicing=False
@@ -2228,10 +2247,12 @@ class SelectInLoader(AbstractRelationshipLoader, util.MemoizedSlots):
                     # imitate the same method that subquery eager loading uses,
                     # looking for the adapted "secondary" table
                     eagerjoin = q._from_obj[0]
-                    eager_order_by = eagerjoin._target_adapter.copy_and_process(
-                        util.to_list(self.parent_property.order_by)
+
+                    return q.order_by(
+                        *eagerjoin._target_adapter.copy_and_process(
+                            util.to_list(self.parent_property.order_by)
+                        )
                     )
-                    return q.order_by(*eager_order_by)
 
                 q.add_criteria(_setup_outermost_orderby)
 
index b2f6bcb11c1fc14488409f39316ae847821b928f..2d0716991827382c69945f988732e388b3b264f4 100644 (file)
@@ -8,24 +8,25 @@
 
 """
 
-from .interfaces import MapperOption, PropComparator, MapperProperty
+from . import util as orm_util
 from .attributes import QueryableAttribute
+from .base import _class_to_mapper
+from .base import _is_aliased_class
+from .base import _is_mapped_class
+from .base import InspectionAttr
+from .interfaces import MapperOption
+from .interfaces import PropComparator
+from .path_registry import _DEFAULT_TOKEN
+from .path_registry import _WILDCARD_TOKEN
+from .path_registry import PathRegistry
+from .path_registry import TokenRegistry
+from .util import _orm_full_deannotate
+from .. import exc as sa_exc
+from .. import inspect
 from .. import util
-from ..sql.base import _generative, Generative
-from .. import exc as sa_exc, inspect
-from .base import (
-    _is_aliased_class,
-    _class_to_mapper,
-    _is_mapped_class,
-    InspectionAttr,
-)
-from . import util as orm_util
-from .path_registry import (
-    PathRegistry,
-    TokenRegistry,
-    _WILDCARD_TOKEN,
-    _DEFAULT_TOKEN,
-)
+from ..sql import expression as sql_expr
+from ..sql.base import _generative
+from ..sql.base import Generative
 
 
 class Load(Generative, MapperOption):
@@ -1454,10 +1455,6 @@ def undefer_group(name):
     return _UnboundLoad().undefer_group(name)
 
 
-from ..sql import expression as sql_expr
-from .util import _orm_full_deannotate
-
-
 @loader_option()
 def with_expression(loadopt, key, expression):
     r"""Apply an ad-hoc SQL expression to a "deferred expression" attribute.
index 0cd488cbd4fc02bb127918f01665ae181057ff7e..2134b6dbf02b62c213bba2ad95250cc1aa9862a6 100644 (file)
@@ -10,7 +10,9 @@ between instances based on join conditions.
 
 """
 
-from . import exc, util as orm_util, attributes
+from . import attributes
+from . import exc
+from . import util as orm_util
 
 
 def populate(
index 545811bb42b813fdd095870381f7fa76dc26dbb4..0d1dae8fc46ae3ed682e5fff7f0cb8feb5e04a38 100644 (file)
@@ -13,11 +13,13 @@ organizes them in order of dependency, and executes.
 
 """
 
-from .. import util, event
-from ..util import topological
-from . import attributes, persistence, util as orm_util
+from . import attributes
 from . import exc as orm_exc
-import itertools
+from . import persistence
+from . import util as orm_util
+from .. import event
+from .. import util
+from ..util import topological
 
 
 def track_cascade_events(descriptor, prop):
index a1b0cd5dadc00b14ce46758fea31a7768c0b4940..4a1e18c1a3e8397033d1d0a6be01c20a8f60ae3a 100644 (file)
@@ -6,26 +6,32 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 
-from .. import sql, util, event, exc as sa_exc, inspection
-from ..sql import expression, util as sql_util, operators
-from .interfaces import PropComparator, MapperProperty
-from . import attributes
 import re
 
-from .base import (
-    instance_str,
-    state_str,
-    state_class_str,
-    attribute_str,
-    state_attribute_str,
-    object_mapper,
-    object_state,
-    _none_set,
-    _never_set,
-)
-from .base import class_mapper, _class_to_mapper
-from .base import InspectionAttr
-from .path_registry import PathRegistry
+from . import attributes  # noqa
+from .base import _class_to_mapper  # noqa
+from .base import _never_set  # noqa
+from .base import _none_set  # noqa
+from .base import attribute_str  # noqa
+from .base import class_mapper  # noqa
+from .base import InspectionAttr  # noqa
+from .base import instance_str  # noqa
+from .base import object_mapper  # noqa
+from .base import object_state  # noqa
+from .base import state_attribute_str  # noqa
+from .base import state_class_str  # noqa
+from .base import state_str  # noqa
+from .interfaces import MapperProperty  # noqa
+from .interfaces import PropComparator  # noqa
+from .path_registry import PathRegistry  # noqa
+from .. import event
+from .. import exc as sa_exc
+from .. import inspection
+from .. import sql
+from .. import util
+from ..sql import expression
+from ..sql import util as sql_util
+
 
 all_cascades = frozenset(
     (
@@ -221,14 +227,14 @@ def polymorphic_union(
                 return sql.type_coerce(sql.null(), types[name]).label(name)
 
     result = []
-    for type, table in table_map.items():
+    for type_, table in table_map.items():
         if typecolname is not None:
             result.append(
                 sql.select(
                     [col(name, table) for name in colnames]
                     + [
                         sql.literal_column(
-                            sql_util._quote_ddl_expr(type)
+                            sql_util._quote_ddl_expr(type_)
                         ).label(typecolname)
                     ],
                     from_obj=[table],
@@ -261,7 +267,7 @@ def identity_key(*args, **kwargs):
 
       :param class: mapped class (must be a positional argument)
       :param ident: primary key, may be a scalar or tuple argument.
-      ;param identity_token: optional identity token
+      :param identity_token: optional identity token
 
         .. versionadded:: 1.2 added identity_token
 
@@ -301,7 +307,7 @@ first()
       :param class: mapped class (must be a positional argument)
       :param row: :class:`.RowProxy` row returned by a :class:`.ResultProxy`
        (must be given as a keyword arg)
-      ;param identity_token: optional identity token
+      :param identity_token: optional identity token
 
         .. versionadded:: 1.2 added identity_token
 
@@ -957,7 +963,14 @@ class _ORMJoin(expression.Join):
             else:
                 adapt_from = left_info.selectable
 
-            pj, sj, source, dest, secondary, target_adapter = prop._create_joins(
+            (
+                pj,
+                sj,
+                source,
+                dest,
+                secondary,
+                target_adapter,
+            ) = prop._create_joins(
                 source_selectable=adapt_from,
                 dest_selectable=adapt_to,
                 source_polymorphic=True,
@@ -1125,7 +1138,7 @@ def with_parent(instance, prop, from_entity=None):
     return prop._with_parent(instance, from_entity=from_entity)
 
 
-def has_identity(object):
+def has_identity(object_):
     """Return True if the given object has a database
     identity.
 
@@ -1137,11 +1150,11 @@ def has_identity(object):
         :func:`.was_deleted`
 
     """
-    state = attributes.instance_state(object)
+    state = attributes.instance_state(object_)
     return state.has_identity
 
 
-def was_deleted(object):
+def was_deleted(object_):
     """Return True if the given object was deleted
     within a session flush.
 
@@ -1156,7 +1169,7 @@ def was_deleted(object):
 
     """
 
-    state = attributes.instance_state(object)
+    state = attributes.instance_state(object_)
     return state.was_deleted
 
 
index 2aa6eeeb7b3ef25b580dc2107ede263516762320..39017906c94776ab9016e4b0e6fb785f57704b5f 100644 (file)
@@ -17,19 +17,36 @@ regular DB-API connect() methods to be transparently managed by a
 SQLAlchemy connection pool.
 """
 
+from .base import _ConnectionFairy  # noqa
+from .base import _ConnectionRecord  # noqa
+from .base import _finalize_fairy  # noqa
 from .base import _refs  # noqa
-from .base import Pool  # noqa
-from .impl import (  # noqa
-    QueuePool,
-    StaticPool,
-    NullPool,
-    AssertionPool,
-    SingletonThreadPool,
-)
-from .dbapi_proxy import manage, clear_managers  # noqa
-
-from .base import reset_rollback, reset_commit, reset_none  # noqa
+from .base import Pool
+from .base import reset_commit
+from .base import reset_none
+from .base import reset_rollback
+from .dbapi_proxy import clear_managers
+from .dbapi_proxy import manage
+from .impl import AssertionPool
+from .impl import NullPool
+from .impl import QueuePool
+from .impl import SingletonThreadPool
+from .impl import StaticPool
+
+
+__all__ = [
+    "Pool",
+    "reset_commit",
+    "reset_none",
+    "reset_rollback",
+    "clear_managers",
+    "manage",
+    "AssertionPool",
+    "NullPool",
+    "QueuePool",
+    "SingletonThreadPool",
+    "StaticPool",
+]
 
 # as these are likely to be used in various test suites, debugging
 # setups, keep them in the sqlalchemy.pool namespace
-from .base import _ConnectionFairy, _ConnectionRecord, _finalize_fairy  # noqa
index 382e740c6b563b0f8ea80c780971c651105cba25..8df0b89c6f810050eebaa293bfef296cc8b44c8f 100644 (file)
@@ -14,7 +14,11 @@ from collections import deque
 import time
 import weakref
 
-from .. import exc, log, event, interfaces, util
+from .. import event
+from .. import exc
+from .. import interfaces
+from .. import log
+from .. import util
 from ..util import threading
 
 
index 425c4a11453b4b8b69e066f8d2c114f767b2c344..ccd157948abab4ca8d348c97895be2f08f6f72b0 100644 (file)
@@ -18,6 +18,7 @@ today.
 from .impl import QueuePool
 from ..util import threading
 
+
 proxies = {}
 
 
index 6159f6a5b38ed4eaa1573711f24de06e43665d44..d1b038d47eb4e383e65e15ee5669586137ef56d2 100644 (file)
 import traceback
 import weakref
 
-from .base import Pool, _ConnectionRecord
+from .base import _ConnectionRecord
+from .base import Pool
 from .. import exc
 from .. import util
-from ..util import queue as sqla_queue
 from ..util import chop_traceback
+from ..util import queue as sqla_queue
 from ..util import threading
 
 
index 46d5dcbc639d7ec9ea104e5917d031fbe35d714f..74a2fe54e60f454cd06044bf2057f4aebe944418 100644 (file)
@@ -14,8 +14,9 @@ They all share one common characteristic: None is passed through unchanged.
 """
 
 import codecs
-import re
 import datetime
+import re
+
 from . import util
 
 
@@ -101,19 +102,19 @@ def py_fallback():
 
         return process
 
-    def to_float(value):
+    def to_float(value):  # noqa
         if value is None:
             return None
         else:
             return float(value)
 
-    def to_str(value):
+    def to_str(value):  # noqa
         if value is None:
             return None
         else:
             return str(value)
 
-    def int_to_boolean(value):
+    def int_to_boolean(value):  # noqa
         if value is None:
             return None
         else:
@@ -125,25 +126,27 @@ def py_fallback():
     TIME_RE = re.compile(r"(\d+):(\d+):(\d+)(?:\.(\d+))?")
     DATE_RE = re.compile(r"(\d+)-(\d+)-(\d+)")
 
-    str_to_datetime = str_to_datetime_processor_factory(
+    str_to_datetime = str_to_datetime_processor_factory(  # noqa
         DATETIME_RE, datetime.datetime
     )
-    str_to_time = str_to_datetime_processor_factory(TIME_RE, datetime.time)
-    str_to_date = str_to_datetime_processor_factory(DATE_RE, datetime.date)
+    str_to_time = str_to_datetime_processor_factory(  # noqa
+        TIME_RE, datetime.time
+    )  # noqa
+    str_to_date = str_to_datetime_processor_factory(  # noqa
+        DATE_RE, datetime.date
+    )  # noqa
     return locals()
 
 
 try:
-    from sqlalchemy.cprocessors import (
-        UnicodeResultProcessor,
-        DecimalResultProcessor,
-        to_float,
-        to_str,
-        int_to_boolean,
-        str_to_datetime,
-        str_to_time,
-        str_to_date,
-    )
+    from sqlalchemy.cprocessors import DecimalResultProcessor  # noqa
+    from sqlalchemy.cprocessors import int_to_boolean  # noqa
+    from sqlalchemy.cprocessors import str_to_date  # noqa
+    from sqlalchemy.cprocessors import str_to_datetime  # noqa
+    from sqlalchemy.cprocessors import str_to_time  # noqa
+    from sqlalchemy.cprocessors import to_float  # noqa
+    from sqlalchemy.cprocessors import to_str  # noqa
+    from sqlalchemy.cprocessors import UnicodeResultProcessor  # noqa
 
     def to_unicode_processor_factory(encoding, errors=None):
         if errors is not None:
index 598d499dc83846e91b67d0b4b3b4a44339c20781..199bb66dcdf49b20b329b92b731c3f9e86579f5e 100644 (file)
@@ -9,60 +9,50 @@
 
 """
 
-from .sql.base import SchemaVisitor
-
-
-from .sql.schema import (
-    BLANK_SCHEMA,
-    CheckConstraint,
-    Column,
-    ColumnDefault,
-    Constraint,
-    DefaultClause,
-    DefaultGenerator,
-    FetchedValue,
-    ForeignKey,
-    ForeignKeyConstraint,
-    Index,
-    MetaData,
-    PassiveDefault,
-    PrimaryKeyConstraint,
-    SchemaItem,
-    Sequence,
-    Table,
-    ThreadLocalMetaData,
-    UniqueConstraint,
-    _get_table_key,
-    ColumnCollectionConstraint,
-    ColumnCollectionMixin,
-)
-
-
-from .sql.naming import conv
-
-
-from .sql.ddl import (
-    DDL,
-    CreateTable,
-    DropTable,
-    CreateSequence,
-    DropSequence,
-    CreateIndex,
-    DropIndex,
-    CreateSchema,
-    DropSchema,
-    _DropView,
-    CreateColumn,
-    AddConstraint,
-    DropConstraint,
-    DDLBase,
-    DDLElement,
-    _CreateDropBase,
-    _DDLCompiles,
-    sort_tables,
-    sort_tables_and_constraints,
-    SetTableComment,
-    DropTableComment,
-    SetColumnComment,
-    DropColumnComment,
-)
+from .sql.base import SchemaVisitor  # noqa
+from .sql.ddl import _CreateDropBase  # noqa
+from .sql.ddl import _DDLCompiles  # noqa
+from .sql.ddl import _DropView  # noqa
+from .sql.ddl import AddConstraint  # noqa
+from .sql.ddl import CreateColumn  # noqa
+from .sql.ddl import CreateIndex  # noqa
+from .sql.ddl import CreateSchema  # noqa
+from .sql.ddl import CreateSequence  # noqa
+from .sql.ddl import CreateTable  # noqa
+from .sql.ddl import DDL  # noqa
+from .sql.ddl import DDLBase  # noqa
+from .sql.ddl import DDLElement  # noqa
+from .sql.ddl import DropColumnComment  # noqa
+from .sql.ddl import DropConstraint  # noqa
+from .sql.ddl import DropIndex  # noqa
+from .sql.ddl import DropSchema  # noqa
+from .sql.ddl import DropSequence  # noqa
+from .sql.ddl import DropTable  # noqa
+from .sql.ddl import DropTableComment  # noqa
+from .sql.ddl import SetColumnComment  # noqa
+from .sql.ddl import SetTableComment  # noqa
+from .sql.ddl import sort_tables  # noqa
+from .sql.ddl import sort_tables_and_constraints  # noqa
+from .sql.naming import conv  # noqa
+from .sql.schema import _get_table_key  # noqa
+from .sql.schema import BLANK_SCHEMA  # noqa
+from .sql.schema import CheckConstraint  # noqa
+from .sql.schema import Column  # noqa
+from .sql.schema import ColumnCollectionConstraint  # noqa
+from .sql.schema import ColumnCollectionMixin  # noqa
+from .sql.schema import ColumnDefault  # noqa
+from .sql.schema import Constraint  # noqa
+from .sql.schema import DefaultClause  # noqa
+from .sql.schema import DefaultGenerator  # noqa
+from .sql.schema import FetchedValue  # noqa
+from .sql.schema import ForeignKey  # noqa
+from .sql.schema import ForeignKeyConstraint  # noqa
+from .sql.schema import Index  # noqa
+from .sql.schema import MetaData  # noqa
+from .sql.schema import PassiveDefault  # noqa
+from .sql.schema import PrimaryKeyConstraint  # noqa
+from .sql.schema import SchemaItem  # noqa
+from .sql.schema import Sequence  # noqa
+from .sql.schema import Table  # noqa
+from .sql.schema import ThreadLocalMetaData  # noqa
+from .sql.schema import UniqueConstraint  # noqa
index 87e2fb6c3959834fa73d08e414ed13447929593f..a46acc076df8944f49a49cf795c41635f556cace 100644 (file)
@@ -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())
index 64cfa630e846a986d7c1945bec2e146e5769fe92..0dc70a81294147573349a14e32be93a2e96df931 100644 (file)
@@ -11,8 +11,8 @@ associations.
 
 """
 
-from .. import util
 from . import operators
+from .. import util
 
 
 class Annotated(object):
index 45db215fee3c84d843faaee4b12bf9228d476bd4..1de7c5ea63bbacacf92012a980ff1df5fddb195d 100644 (file)
 """
 
 
-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)
index f641d0a8440c72b6a40f6ddb0f98ad291dc3e6d7..c752da0136dd1591f73d8dc0d0f69bbeba6556c8 100644 (file)
@@ -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
 
index 602b91a25532ed85fc17fe31a2496b1eaf27f208..6452badd24706c96bf5b7ee5ed3aa79d4acc2d12 100644 (file)
@@ -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 = [
index f21b3d7f062563dfbd23be6e108a24fc8b69a4ad..f247fa782374a911245d0fbbf73d224220a73d46 100644 (file)
@@ -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"):
index fa0052198732ca482afbca1c14d85e7d845988dd..69196341f6134be7673d6ff5ab6df6a9a9447014 100644 (file)
@@ -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(
index 0cea5ccc422e05bf509e26eaf87d785ba78bd355..39a3b39d38ac83fabd4f7dc03aa9fd84dd5c12c0 100644 (file)
@@ -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
index e857f2da8516ce0603591ad66e0b6b078f0a51a2..858695719cb9099a60422c29f4be0ab436ef745c 100644 (file)
 
 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
 
index aab9f46d43fb0caea5c11b16f25f79a04b3274b2..d8e5f170af9edc7a29bd896b2ca9046b71ec8800 100644 (file)
@@ -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
index 883bb8cc3cfb10404af81e7ab45ee91ee85b6cc9..e191cff155c8d2781348ee957472b37e45efc265 100644 (file)
@@ -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.
 
     """
 
index 144cc4dfc8cc9e86d326fa39a240d337b45697e1..ec6bc6a3ba16f2d8342a91a93fc1e3d05787c869 100644 (file)
 
 """
 
-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):
index 2b843d751ce077dde16de997e8a8a2ac067a0ed4..379e7337f2f8e95b3f768a86ea39581ccdab172e 100644 (file)
 
 """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
index d6c3f5000b3caaf410eb7e9740b07e02e049768b..804c8bdb8409397d56945bd0bf76963b442d1ef2 100644 (file)
@@ -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::
 
index 1f1800514f45e9bf3f8243f61581355f4365fa25..beba1d24293662ff8573cafc30e1b61e4975bea4 100644 (file)
@@ -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::
index 61fc6d3c96d4ada66b0343926ffd0f6913593da2..65527645bc57bd2c509aaf91e4daf24a3ec5e7dc 100644 (file)
@@ -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
index 7fe7807832696f0bc7df729a9b84f2c505bdebc7..647c3e776d92cf8fc7592c4a0b681eb1282d48f3 100644 (file)
 """
 
 
-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
index 4feaf9938980ec1bd04815363bb9683c58c95c1d..604b3cfd9cd59d238a730e816837229e148b7d38 100644 (file)
@@ -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,
index bf17436436650f2947dde8511a418b9624fe2d5e..d4b72dd5976d2e4583503b223fe3c06d37e0bcac 100644 (file)
@@ -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",
index f46ca4528ac708dc459984cf1fb36319bddb787c..e41c3addf2d424853d87dfa6ad5d723b135b436e 100644 (file)
@@ -6,70 +6,58 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 
-from .warnings import assert_warnings
-
-from . import config
-
-from .exclusions import (
-    db_spec,
-    _is_excluded,
-    fails_if,
-    skip_if,
-    future,
-    fails_on,
-    fails_on_everything_except,
-    skip,
-    only_on,
-    exclude,
-    against as _against,
-    _server_version,
-    only_if,
-    fails,
-)
+from . import config  # noqa
+from . import mock  # noqa
+from .assertions import assert_raises  # noqa
+from .assertions import assert_raises_message  # noqa
+from .assertions import AssertsCompiledSQL  # noqa
+from .assertions import AssertsExecutionResults  # noqa
+from .assertions import ComparesTables  # noqa
+from .assertions import emits_warning  # noqa
+from .assertions import emits_warning_on  # noqa
+from .assertions import eq_  # noqa
+from .assertions import eq_ignore_whitespace  # noqa
+from .assertions import eq_regex  # noqa
+from .assertions import expect_deprecated  # noqa
+from .assertions import expect_warnings  # noqa
+from .assertions import in_  # noqa
+from .assertions import is_  # noqa
+from .assertions import is_false  # noqa
+from .assertions import is_not_  # noqa
+from .assertions import is_true  # noqa
+from .assertions import le_  # noqa
+from .assertions import ne_  # noqa
+from .assertions import not_in_  # noqa
+from .assertions import startswith_  # noqa
+from .assertions import uses_deprecated  # noqa
+from .config import db  # noqa
+from .config import requirements as requires  # noqa
+from .exclusions import _is_excluded  # noqa
+from .exclusions import _server_version  # noqa
+from .exclusions import against as _against  # noqa
+from .exclusions import db_spec  # noqa
+from .exclusions import exclude  # noqa
+from .exclusions import fails  # noqa
+from .exclusions import fails_if  # noqa
+from .exclusions import fails_on  # noqa
+from .exclusions import fails_on_everything_except  # noqa
+from .exclusions import future  # noqa
+from .exclusions import only_if  # noqa
+from .exclusions import only_on  # noqa
+from .exclusions import skip  # noqa
+from .exclusions import skip_if  # noqa
+from .util import adict  # noqa
+from .util import fail  # noqa
+from .util import force_drop_names  # noqa
+from .util import provide_metadata  # noqa
+from .util import rowset  # noqa
+from .util import run_as_contextmanager  # noqa
+from .util import teardown_events  # noqa
+from .warnings import assert_warnings  # noqa
 
 
 def against(*queries):
     return _against(config._current, *queries)
 
 
-from .assertions import (
-    emits_warning,
-    emits_warning_on,
-    uses_deprecated,
-    eq_,
-    ne_,
-    le_,
-    is_,
-    is_not_,
-    startswith_,
-    assert_raises,
-    assert_raises_message,
-    AssertsCompiledSQL,
-    ComparesTables,
-    AssertsExecutionResults,
-    expect_deprecated,
-    expect_warnings,
-    in_,
-    not_in_,
-    eq_ignore_whitespace,
-    eq_regex,
-    is_true,
-    is_false,
-)
-
-from .util import (
-    run_as_contextmanager,
-    rowset,
-    fail,
-    provide_metadata,
-    adict,
-    force_drop_names,
-    teardown_events,
-)
-
 crashes = skip
-
-from .config import db
-from .config import requirements as requires
-
-from . import mock
index 73ab4556af8867d001108d0c5cfc57611582b19d..11b77d72abc55fcd5ea270a5a482be784af36c17 100644 (file)
@@ -7,19 +7,26 @@
 
 from __future__ import absolute_import
 
-from . import util as testutil
-from sqlalchemy import pool, orm, util
-from sqlalchemy.engine import default, url
-from sqlalchemy.util import decorator, compat
-from sqlalchemy import types as sqltypes, schema, exc as sa_exc
-import warnings
+import contextlib
 import re
-from .exclusions import db_spec
+import warnings
+
 from . import assertsql
 from . import config
-from .util import fail
-import contextlib
 from . import mock
+from . import util as testutil
+from .exclusions import db_spec
+from .util import fail
+from .. import exc as sa_exc
+from .. import orm
+from .. import pool
+from .. import schema
+from .. import types as sqltypes
+from .. import util
+from ..engine import default
+from ..engine import url
+from ..util import compat
+from ..util import decorator
 
 
 def expect_warnings(*messages, **kw):
@@ -442,15 +449,15 @@ class AssertsExecutionResults(object):
         print(repr(result))
         self.assert_list(result, class_, objects)
 
-    def assert_list(self, result, class_, list):
+    def assert_list(self, result, class_, list_):
         self.assert_(
-            len(result) == len(list),
+            len(result) == len(list_),
             "result list is not the same size as test list, "
             + "for class "
             + class_.__name__,
         )
-        for i in range(0, len(list)):
-            self.assert_row(class_, result[i], list[i])
+        for i in range(0, len(list_)):
+            self.assert_row(class_, result[i], list_[i])
 
     def assert_row(self, class_, rowobj, desc):
         self.assert_(
index d8e924cb616e23d974c513b45301b72d24554c22..1d3cfe0e1e7c2b47f9be7be614d340b5476ceb22 100644 (file)
@@ -5,15 +5,16 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from ..engine.default import DefaultDialect
-from .. import util
-import re
 import collections
 import contextlib
+import re
+
 from .. import event
-from sqlalchemy.schema import _DDLCompiles
-from sqlalchemy.engine.util import _distill_params
-from sqlalchemy.engine import url
+from .. import util
+from ..engine import url
+from ..engine.default import DefaultDialect
+from ..engine.util import _distill_params
+from ..schema import _DDLCompiles
 
 
 class AssertRule(object):
index 074e3b33878c92f128116f0cd3b01d9be9324bb6..bfb1a24b5cf5f23b2f057ed316cc6c958cc665db 100644 (file)
@@ -7,12 +7,14 @@
 
 from __future__ import absolute_import
 
+import re
+import warnings
 import weakref
+
 from . import config
 from .util import decorator
-from .. import event, pool
-import re
-import warnings
+from .. import event
+from .. import pool
 
 
 class ConnectionKiller(object):
index 42c42149ca0764b7b997d52f36e4bdb1a5b33ed4..a14304b9722d26e1084dd52d69e41597c1f4e13c 100644 (file)
@@ -6,7 +6,8 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 import sqlalchemy as sa
-from sqlalchemy import exc as sa_exc
+from .. import exc as sa_exc
+
 
 _repr_stack = set()
 
index 9ed9e42c3a2a38b251f15fb1bfeadde911930fc6..ffca84af1f68d4b8fc63a1a1e783f6b8eb4fcc67 100644 (file)
@@ -10,11 +10,10 @@ import contextlib
 import operator
 import re
 
-from sqlalchemy.util.compat import inspect_getargspec
-
 from . import config
 from .. import util
 from ..util import decorator
+from ..util.compat import inspect_getargspec
 
 
 def skip_if(predicate, reason=None):
@@ -399,7 +398,7 @@ def db_spec(*dbs):
     return OrPredicate([Predicate.as_predicate(db) for db in dbs])
 
 
-def open():
+def open():  # noqa
     return skip_if(BooleanPredicate(False, "mark as execute"))
 
 
index 98184cdd47fc49bf2fd2e6bc4eedd9aa5407ad8d..b0f3590ee3dc32d1529a96a6dcbc935ddbbd47c9 100644 (file)
@@ -5,15 +5,21 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
+import sys
+
+import sqlalchemy as sa
+from . import assertions
 from . import config
-from . import assertions, schema
+from . import schema
+from .engines import drop_all_tables
+from .entities import BasicEntity
+from .entities import ComparableEntity
 from .util import adict
+from .. import event
 from .. import util
-from .engines import drop_all_tables
-from .entities import BasicEntity, ComparableEntity
-import sys
-import sqlalchemy as sa
-from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
+from ..ext.declarative import declarative_base
+from ..ext.declarative import DeclarativeMeta
+
 
 # whether or not we use unittest changes things dramatically,
 # as far as how py.test collection works.
@@ -220,9 +226,6 @@ class TablesTest(TestBase):
             )
 
 
-from sqlalchemy import event
-
-
 class RemovesEvents(object):
     @util.memoized_property
     def _event_fns(self):
index dc530af5eb7306dc9b2da02f9bee1f6419b23be2..0b84d7db813e1f2110dac6b656d38c5d71402983 100644 (file)
@@ -8,13 +8,23 @@
 """Import stub for mock library.
 """
 from __future__ import absolute_import
+
 from ..util import py33
 
+
 if py33:
-    from unittest.mock import MagicMock, Mock, call, patch, ANY
+    from unittest.mock import MagicMock
+    from unittest.mock import Mock
+    from unittest.mock import call
+    from unittest.mock import patch
+    from unittest.mock import ANY
 else:
     try:
-        from mock import MagicMock, Mock, call, patch, ANY
+        from mock import MagicMock  # noqa
+        from mock import Mock  # noqa
+        from mock import call  # noqa
+        from mock import patch  # noqa
+        from mock import ANY  # noqa
     except ImportError:
         raise ImportError(
             "SQLAlchemy's test suite requires the "
index bb52c125c6aab7c6ae2120a35595147bb4144421..2230ae2a86072efccc9b845b2355fd95e7d3cc24 100644 (file)
@@ -20,6 +20,7 @@ this should be removable when Alembic targets SQLAlchemy 1.0.0.
 import os
 import sys
 
+
 bootstrap_file = locals()["bootstrap_file"]
 to_bootstrap = locals()["to_bootstrap"]
 
index 0c28a52136f3bb457823376c21e3497b55c59fa7..07185a9d7a1301b6705993b5e2124833277d24c7 100644 (file)
@@ -23,8 +23,9 @@ except ImportError:
 import os
 import sys
 
-from nose.plugins import Plugin
 import nose
+from nose.plugins import Plugin
+
 
 fixtures = None
 
index 5d6bf2975ebc942d7d79054ef8c40765d7f6346f..537ab06dc8d364e79e36cf552283676b80973103 100644 (file)
@@ -15,8 +15,9 @@ functionality via py.test.
 
 from __future__ import absolute_import
 
-import sys
 import re
+import sys
+
 
 py3k = sys.version_info >= (3, 0)
 
@@ -245,7 +246,8 @@ def post_begin():
 
     # late imports, has to happen after config as well
     # as nose plugins like coverage
-    global util, fixtures, engines, exclusions, assertions, warnings, profiling, config, testing
+    global util, fixtures, engines, exclusions, assertions
+    global warnings, profiling, config, testing
     from sqlalchemy import testing  # noqa
     from sqlalchemy.testing import fixtures, engines, exclusions  # noqa
     from sqlalchemy.testing import assertions, warnings, profiling  # noqa
@@ -525,8 +527,8 @@ def generate_sub_tests(cls, module):
             # pytest junit plugin, which is tripped up by the brackets
             # and periods, so sanitize
 
-            alpha_name = re.sub("[_\[\]\.]+", "_", cfg.name)
-            alpha_name = re.sub("_+$", "", alpha_name)
+            alpha_name = re.sub(r"[_\[\]\.]+", "_", cfg.name)
+            alpha_name = re.sub(r"_+$", "", alpha_name)
             name = "%s_%s" % (cls.__name__, alpha_name)
             subcls = type(
                 name,
index fd0a484629e9b66d329ead167196c3409fb3027c..f42fc4791477dae2a94900ecc3529dc36ed85599 100644 (file)
@@ -5,12 +5,14 @@ except ImportError:
     # assume we're a package, use traditional import
     from . import plugin_base
 
-import pytest
 import argparse
-import inspect
 import collections
+import inspect
 import os
 
+import pytest
+
+
 try:
     import xdist  # noqa
 
@@ -44,7 +46,7 @@ def pytest_addoption(parser):
                     dest,
                     default=False,
                     required=False,
-                    help=None,
+                    help=None,  # noqa
                 ):
                     super(CallableAction, self).__init__(
                         option_strings=option_strings,
index 3986985c7f3b3ec992baa85995a8df06a37fc829..753cfa59531759ddb3c7b9b4a668a3df006fb555 100644 (file)
@@ -12,19 +12,24 @@ in a more fine-grained way than nose's profiling plugin.
 
 """
 
+import collections
+import contextlib
 import os
+import pstats
 import sys
-from .util import gc_collect
+
 from . import config
-import pstats
-import collections
-import contextlib
+from .util import gc_collect
+from ..util import jython
+from ..util import pypy
+from ..util import update_wrapper
+from ..util import win32
+
 
 try:
     import cProfile
 except ImportError:
     cProfile = None
-from ..util import jython, pypy, win32, update_wrapper
 
 _current_test = None
 
index 25028ccb3ee567fb739d9840ccb46ea8480c2866..88dc28528a6262f1f087f48f4e9bfb12a7d316f9 100644 (file)
@@ -1,13 +1,16 @@
-from sqlalchemy.engine import url as sa_url
-from sqlalchemy import create_engine
-from sqlalchemy import text
-from sqlalchemy import exc
-from sqlalchemy.util import compat
-from . import config, engines
 import collections
+import logging
 import os
 import time
-import logging
+
+from . import config
+from . import engines
+from .. import create_engine
+from .. import exc
+from .. import text
+from ..engine import url as sa_url
+from ..util import compat
+
 
 log = logging.getLogger(__name__)
 
@@ -190,6 +193,8 @@ def _pg_create_db(cfg, eng, ident):
                         template_db,
                     )
                     time.sleep(0.5)
+            except:
+                raise
             else:
                 break
 
@@ -395,7 +400,8 @@ def _mssql_drop_ignore(conn, ident):
     try:
         # typically when this happens, we can't KILL the session anyway,
         # so let the cleanup process drop the DBs
-        # for row in conn.execute("select session_id from sys.dm_exec_sessions "
+        # for row in conn.execute(
+        #     "select session_id from sys.dm_exec_sessions "
         #        "where database_id=db_id('%s')" % ident):
         #    log.info("killing SQL server sesssion %s", row['session_id'])
         #    conn.execute("kill %s" % row['session_id'])
index 9832b07a289189336850b8a5e8ba12891ec2a959..613d7572bbff10fe1064389b81e7c1676922e717 100644 (file)
@@ -1,13 +1,14 @@
-from . import fixtures
-from . import profiling
-from .. import util
-import types
 from collections import deque
 import contextlib
+import types
+
 from . import config
-from sqlalchemy import MetaData
-from sqlalchemy import create_engine
-from sqlalchemy.orm import Session
+from . import fixtures
+from . import profiling
+from .. import create_engine
+from .. import MetaData
+from .. import util
+from ..orm import Session
 
 
 class ReplayFixtureTest(fixtures.TestBase):
@@ -19,7 +20,10 @@ class ReplayFixtureTest(fixtures.TestBase):
 
         dbapi_session = ReplayableSession()
         creator = config.db.pool._creator
-        recorder = lambda: dbapi_session.recorder(creator())
+
+        def recorder():
+            return dbapi_session.recorder(creator())
+
         engine = create_engine(
             config.db.url, creator=recorder, use_native_hstore=False
         )
@@ -34,7 +38,9 @@ class ReplayFixtureTest(fixtures.TestBase):
             self.teardown_engine()
             engine.dispose()
 
-        player = lambda: dbapi_session.player()
+        def player():
+            return dbapi_session.player()
+
         engine = create_engine(
             config.db.url, creator=player, use_native_hstore=False
         )
index c96d26d322a59570446283fd93e1bcb8e1424429..941a9458b78dbd0296cc097d92acd4211cb59146 100644 (file)
@@ -243,7 +243,9 @@ class SuiteRequirements(Requirements):
     @property
     def sane_rowcount_w_returning(self):
         return exclusions.fails_if(
-            lambda config: not config.db.dialect.supports_sane_rowcount_returning,
+            lambda config: not (
+                config.db.dialect.supports_sane_rowcount_returning
+            ),
             "driver doesn't support 'sane' rowcount when returning is on",
         )
 
@@ -758,12 +760,13 @@ class SuiteRequirements(Requirements):
         present in a subquery in the WHERE clause.
 
         This is an ANSI-standard syntax that apparently MySQL can't handle,
-        such as:
+        such as::
+
+            UPDATE documents SET flag=1 WHERE documents.title IN
+                (SELECT max(documents.title) AS title
+                    FROM documents GROUP BY documents.user_id
+                )
 
-        UPDATE documents SET flag=1 WHERE documents.title IN
-            (SELECT max(documents.title) AS title
-                FROM documents GROUP BY documents.user_id
-            )
         """
         return exclusions.open()
 
@@ -944,7 +947,7 @@ class SuiteRequirements(Requirements):
 
     def _has_cextensions(self):
         try:
-            from sqlalchemy import cresultproxy, cprocessors
+            from sqlalchemy import cresultproxy, cprocessors  # noqa
 
             return True
         except ImportError:
index 6aa820fd5707cf2792a1a1eff6cc8d9e7a7cc5b5..b4478bedccdd575c2c8d2dccf2957901e0ed4b1e 100644 (file)
@@ -30,10 +30,10 @@ SQLAlchemy itself is possible.
 
 """
 
-from .plugin.noseplugin import NoseSQLAlchemy
-
 import nose
 
+from .plugin.noseplugin import NoseSQLAlchemy
+
 
 def main():
     nose.main(addplugins=[NoseSQLAlchemy()])
index b345a9487416112a3bdfb62f73ce641f9e3d8e46..c80325b7c214cf1b18f262a60d650fe9183c240e 100644 (file)
@@ -5,11 +5,13 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import exclusions
-from .. import schema, event
 from . import config
+from . import exclusions
+from .. import event
+from .. import schema
+
 
-__all__ = "Table", "Column"
+__all__ = ["Table", "Column"]
 
 table_options = {}
 
index a4e142c5a3f07e551f5747f4354f5cb8391052bb..465a6cfc5719953884e40a71600016413ba68f8e 100644 (file)
@@ -1,10 +1,10 @@
-from sqlalchemy.testing.suite.test_cte import *
-from sqlalchemy.testing.suite.test_dialect import *
-from sqlalchemy.testing.suite.test_ddl import *
-from sqlalchemy.testing.suite.test_insert import *
-from sqlalchemy.testing.suite.test_sequence import *
-from sqlalchemy.testing.suite.test_select import *
-from sqlalchemy.testing.suite.test_results import *
-from sqlalchemy.testing.suite.test_update_delete import *
-from sqlalchemy.testing.suite.test_reflection import *
-from sqlalchemy.testing.suite.test_types import *
+from .test_cte import *  # noqa
+from .test_ddl import *  # noqa
+from .test_dialect import *  # noqa
+from .test_insert import *  # noqa
+from .test_reflection import *  # noqa
+from .test_results import *  # noqa
+from .test_select import *  # noqa
+from .test_sequence import *  # noqa
+from .test_types import *  # noqa
+from .test_update_delete import *  # noqa
index d2f35933bba348784a15e062570259a369d072cb..012de7911d9e08266a46fb09b9ebc0733fe0abdc 100644 (file)
@@ -1,11 +1,13 @@
-from .. import fixtures, config
+from .. import config
+from .. import fixtures
 from ..assertions import eq_
-
-from sqlalchemy import Integer, String, select
-from sqlalchemy import ForeignKey
-from sqlalchemy import testing
-
-from ..schema import Table, Column
+from ..schema import Column
+from ..schema import Table
+from ... import ForeignKey
+from ... import Integer
+from ... import select
+from ... import String
+from ... import testing
 
 
 class CTETest(fixtures.TablesTest):
index 7c44388d4461d373a62b76de02ccf70c533776d7..8317590c810fe36a7100943062f8e5956d248ee4 100644 (file)
@@ -1,8 +1,12 @@
-from .. import fixtures, config, util
-from ..config import requirements
+from .. import config
+from .. import fixtures
+from .. import util
 from ..assertions import eq_
-
-from sqlalchemy import Table, Column, Integer, String
+from ..config import requirements
+from ... import Column
+from ... import Integer
+from ... import String
+from ... import Table
 
 
 class TableDDLTest(fixtures.TestBase):
index 5e589f3b8814b074332a9cdeb58018d4be064b61..245ccc6f0775e11d38a71c2c1d6da300c8129768 100644 (file)
@@ -1,11 +1,16 @@
-from .. import fixtures, config
-from ..config import requirements
-from sqlalchemy import exc
-from sqlalchemy import Integer, String, select, literal_column
 from .. import assert_raises
-from ..schema import Table, Column
-from .. import provide_metadata
+from .. import config
 from .. import eq_
+from .. import fixtures
+from .. import provide_metadata
+from ..config import requirements
+from ..schema import Column
+from ..schema import Table
+from ... import exc
+from ... import Integer
+from ... import literal_column
+from ... import select
+from ... import String
 
 
 class ExceptionTest(fixtures.TablesTest):
index 6257451eb05d94695597f903c6f3c919c29d90de..1b14e8ed812832907f25fda3c28ae1ce24acd55f 100644 (file)
@@ -1,12 +1,15 @@
-from .. import fixtures, config
-from ..config import requirements
-from .. import exclusions
-from ..assertions import eq_
+from .. import config
 from .. import engines
-
-from sqlalchemy import Integer, String, select, literal_column, literal
-
-from ..schema import Table, Column
+from .. import fixtures
+from ..assertions import eq_
+from ..config import requirements
+from ..schema import Column
+from ..schema import Table
+from ... import Integer
+from ... import literal
+from ... import literal_column
+from ... import select
+from ... import String
 
 
 class LastrowidTest(fixtures.TablesTest):
index bfed5f1ab51f05e605daca21c89e52c8ee5444ae..96bd188eedee657d9d818fccc2435d792eada9f2 100644 (file)
@@ -1,21 +1,30 @@
-import sqlalchemy as sa
-from sqlalchemy import exc as sa_exc
-from sqlalchemy import types as sql_types
-from sqlalchemy import inspect
-from sqlalchemy import MetaData, Integer, String, func
-from sqlalchemy.engine.reflection import Inspector
-from sqlalchemy.testing import engines, fixtures
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.testing import eq_, is_, assert_raises_message
-from sqlalchemy import testing
-from .. import config
 import operator
-from sqlalchemy.schema import DDL, Index
-from sqlalchemy import event
-from sqlalchemy.sql.elements import quoted_name
-from sqlalchemy import ForeignKey
 import re
 
+import sqlalchemy as sa
+from .. import assert_raises_message
+from .. import config
+from .. import engines
+from .. import eq_
+from .. import fixtures
+from .. import is_
+from ..schema import Column
+from ..schema import Table
+from ... import event
+from ... import exc as sa_exc
+from ... import ForeignKey
+from ... import inspect
+from ... import Integer
+from ... import MetaData
+from ... import String
+from ... import testing
+from ... import types as sql_types
+from ...engine.reflection import Inspector
+from ...schema import DDL
+from ...schema import Index
+from ...sql.elements import quoted_name
+
+
 metadata, users = None, None
 
 
@@ -367,7 +376,9 @@ class ComponentReflectionTest(fixtures.TablesTest):
                 {"comment": "id comment", "name": "id"},
                 {"comment": "data % comment", "name": "data"},
                 {
-                    "comment": r"""Comment types type speedily ' " \ '' Fun!""",
+                    "comment": (
+                        r"""Comment types type speedily ' " \ '' Fun!"""
+                    ),
                     "name": "d2",
                 },
             ],
index 247f05cf5f0f5ceadb424ec0eedb2e5fb181629e..aa98a508821b0512882bd80d43064cd3b09dac71 100644 (file)
@@ -1,13 +1,20 @@
-from .. import fixtures, config
-from ..config import requirements
-from .. import exclusions
-from ..assertions import eq_
+import datetime
+
+from .. import config
 from .. import engines
+from .. import fixtures
+from ..assertions import eq_
+from ..config import requirements
+from ..schema import Column
+from ..schema import Table
+from ... import DateTime
+from ... import func
+from ... import Integer
+from ... import select
+from ... import sql
+from ... import String
 from ... import testing
-
-from sqlalchemy import Integer, String, select, util, sql, DateTime, text, func
-import datetime
-from ..schema import Table, Column
+from ... import text
 
 
 class RowFetchTest(fixtures.TablesTest):
index 032b68eb62419529316f1407fcfd5dd727301a96..d2658514190e9eb31b21ac456fff365b90325dec 100644 (file)
@@ -1,14 +1,23 @@
-from sqlalchemy.dialects.mssql.base import MSDialect
-from sqlalchemy.dialects.oracle.base import OracleDialect
-from .. import fixtures, config
-from ..assertions import eq_, in_
-
-from sqlalchemy import util, case, null, true, false, or_
-from sqlalchemy import Integer, String, select, func, bindparam, union, tuple_
-from sqlalchemy import testing
-from sqlalchemy import literal_column
-
-from ..schema import Table, Column
+from .. import config
+from .. import fixtures
+from ..assertions import eq_
+from ..assertions import in_
+from ..schema import Column
+from ..schema import Table
+from ... import bindparam
+from ... import case
+from ... import false
+from ... import func
+from ... import Integer
+from ... import literal_column
+from ... import null
+from ... import select
+from ... import String
+from ... import testing
+from ... import true
+from ... import tuple_
+from ... import union
+from ... import util
 
 
 class CollateTest(fixtures.TablesTest):
index 15a850fe9e1a325da204e0b01f15a1ae152526a1..22ae7d43cf5551276eac7f498e11e405625eaa60 100644 (file)
@@ -1,12 +1,16 @@
-from .. import fixtures, config
-from ..config import requirements
+from .. import config
+from .. import fixtures
 from ..assertions import eq_
+from ..config import requirements
+from ..schema import Column
+from ..schema import Table
+from ... import Integer
+from ... import MetaData
+from ... import schema
+from ... import Sequence
+from ... import String
 from ... import testing
 
-from ... import Integer, String, Sequence, schema, MetaData
-
-from ..schema import Table, Column
-
 
 class SequenceTest(fixtures.TablesTest):
     __requires__ = ("sequences",)
index 6dfb80915a5e5e5ec576524ae29a330af842e251..ff8db5897cf47109b7fc10526601c639fa791524 100644 (file)
@@ -1,33 +1,40 @@
 # coding: utf-8
 
-from .. import fixtures, config
+import datetime
+import decimal
+
+from .. import config
+from .. import fixtures
 from ..assertions import eq_
 from ..config import requirements
-from sqlalchemy import Integer, Unicode, UnicodeText, select, TIMESTAMP
-from sqlalchemy import (
-    Date,
-    DateTime,
-    Time,
-    MetaData,
-    String,
-    Text,
-    Numeric,
-    Float,
-    literal,
-    Boolean,
-    cast,
-    null,
-    JSON,
-    and_,
-    type_coerce,
-    BigInteger,
-)
-from ..schema import Table, Column
+from ..schema import Column
+from ..schema import Table
+from ... import and_
+from ... import BigInteger
+from ... import Boolean
+from ... import cast
+from ... import Date
+from ... import DateTime
+from ... import Float
+from ... import Integer
+from ... import JSON
+from ... import literal
+from ... import MetaData
+from ... import null
+from ... import Numeric
+from ... import select
+from ... import String
 from ... import testing
-import decimal
-import datetime
-from ...util import u
+from ... import Text
+from ... import Time
+from ... import TIMESTAMP
+from ... import type_coerce
+from ... import Unicode
+from ... import UnicodeText
 from ... import util
+from ...ext.declarative import declarative_base
+from ...orm import Session
+from ...util import u
 
 
 class _LiteralRoundTripFixture(object):
@@ -341,7 +348,7 @@ class IntegerTest(_LiteralRoundTripFixture, fixtures.TestBase):
         if util.py3k:
             assert isinstance(row[0], int)
         else:
-            assert isinstance(row[0], (long, int))
+            assert isinstance(row[0], (long, int))  # noqa
 
 
 class NumericTest(_LiteralRoundTripFixture, fixtures.TestBase):
@@ -872,8 +879,6 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
             )
 
     def test_eval_none_flag_orm(self):
-        from sqlalchemy.ext.declarative import declarative_base
-        from sqlalchemy.orm import Session
 
         Base = declarative_base()
 
index b232c3a7868e5a271fb73038739e8d32ac39cc5c..97bdf0ad76d2a32a62d09845427361db623417da 100644 (file)
@@ -1,8 +1,10 @@
-from .. import fixtures, config
+from .. import config
+from .. import fixtures
 from ..assertions import eq_
-
-from sqlalchemy import Integer, String
-from ..schema import Table, Column
+from ..schema import Column
+from ..schema import Table
+from ... import Integer
+from ... import String
 
 
 class SimpleUpdateDeleteTest(fixtures.TablesTest):
index 5b015d2142cfc3f4c6e14fe414dae2edae00642a..214afa07820f025c5d6a6b4b83f947b46738e2d8 100644 (file)
@@ -5,14 +5,20 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from ..util import jython, pypy, defaultdict, decorator, py2k
 import decimal
 import gc
-import time
 import random
 import sys
+import time
 import types
 
+from ..util import decorator
+from ..util import defaultdict
+from ..util import jython
+from ..util import py2k
+from ..util import pypy
+
+
 if jython:
 
     def jython_gc_collect(*args):
index e0101b14d150613845399e8da7f897957aa10b51..611389fe02f52a1c0674f1853607dff2f1208bf0 100644 (file)
@@ -8,8 +8,9 @@
 from __future__ import absolute_import
 
 import warnings
-from .. import exc as sa_exc
+
 from . import assertions
+from .. import exc as sa_exc
 
 
 def setup_filters():
index e665828014e2a0c9588750728f473d40eae4a42e..4cdc18d97a2c0c7a03fdf4cdcc39ccf3948af303 100644 (file)
@@ -59,63 +59,59 @@ __all__ = [
     "JSON",
 ]
 
-from .sql.type_api import (
-    adapt_type,
-    TypeEngine,
-    TypeDecorator,
-    Variant,
-    to_instance,
-    UserDefinedType,
-)
-from .sql.sqltypes import (
-    ARRAY,
-    BIGINT,
-    BINARY,
-    BLOB,
-    BOOLEAN,
-    BigInteger,
-    Binary,
-    _Binary,
-    Boolean,
-    CHAR,
-    CLOB,
-    Concatenable,
-    DATE,
-    DATETIME,
-    DECIMAL,
-    Date,
-    DateTime,
-    Enum,
-    FLOAT,
-    Float,
-    Indexable,
-    INT,
-    INTEGER,
-    Integer,
-    Interval,
-    JSON,
-    LargeBinary,
-    MatchType,
-    NCHAR,
-    NVARCHAR,
-    NullType,
-    NULLTYPE,
-    NUMERIC,
-    Numeric,
-    PickleType,
-    REAL,
-    SchemaType,
-    SMALLINT,
-    SmallInteger,
-    String,
-    STRINGTYPE,
-    TEXT,
-    TIME,
-    TIMESTAMP,
-    Text,
-    Time,
-    Unicode,
-    UnicodeText,
-    VARBINARY,
-    VARCHAR,
-)
+from .sql.sqltypes import _Binary  # noqa
+from .sql.sqltypes import ARRAY  # noqa
+from .sql.sqltypes import BIGINT  # noqa
+from .sql.sqltypes import BigInteger  # noqa
+from .sql.sqltypes import BINARY  # noqa
+from .sql.sqltypes import Binary  # noqa
+from .sql.sqltypes import BLOB  # noqa
+from .sql.sqltypes import BOOLEAN  # noqa
+from .sql.sqltypes import Boolean  # noqa
+from .sql.sqltypes import CHAR  # noqa
+from .sql.sqltypes import CLOB  # noqa
+from .sql.sqltypes import Concatenable  # noqa
+from .sql.sqltypes import DATE  # noqa
+from .sql.sqltypes import Date  # noqa
+from .sql.sqltypes import DATETIME  # noqa
+from .sql.sqltypes import DateTime  # noqa
+from .sql.sqltypes import DECIMAL  # noqa
+from .sql.sqltypes import Enum  # noqa
+from .sql.sqltypes import FLOAT  # noqa
+from .sql.sqltypes import Float  # noqa
+from .sql.sqltypes import Indexable  # noqa
+from .sql.sqltypes import INT  # noqa
+from .sql.sqltypes import INTEGER  # noqa
+from .sql.sqltypes import Integer  # noqa
+from .sql.sqltypes import Interval  # noqa
+from .sql.sqltypes import JSON  # noqa
+from .sql.sqltypes import LargeBinary  # noqa
+from .sql.sqltypes import MatchType  # noqa
+from .sql.sqltypes import NCHAR  # noqa
+from .sql.sqltypes import NULLTYPE  # noqa
+from .sql.sqltypes import NullType  # noqa
+from .sql.sqltypes import NUMERIC  # noqa
+from .sql.sqltypes import Numeric  # noqa
+from .sql.sqltypes import NVARCHAR  # noqa
+from .sql.sqltypes import PickleType  # noqa
+from .sql.sqltypes import REAL  # noqa
+from .sql.sqltypes import SchemaType  # noqa
+from .sql.sqltypes import SMALLINT  # noqa
+from .sql.sqltypes import SmallInteger  # noqa
+from .sql.sqltypes import String  # noqa
+from .sql.sqltypes import STRINGTYPE  # noqa
+from .sql.sqltypes import TEXT  # noqa
+from .sql.sqltypes import Text  # noqa
+from .sql.sqltypes import TIME  # noqa
+from .sql.sqltypes import Time  # noqa
+from .sql.sqltypes import TIMESTAMP  # noqa
+from .sql.sqltypes import Unicode  # noqa
+from .sql.sqltypes import UnicodeText  # noqa
+from .sql.sqltypes import VARBINARY  # noqa
+from .sql.sqltypes import VARCHAR  # noqa
+from .sql.type_api import adapt_type  # noqa
+from .sql.type_api import to_instance  # noqa
+from .sql.type_api import TypeDecorator  # noqa
+from .sql.type_api import TypeEngine  # noqa
+from .sql.type_api import UserDefinedType  # noqa
+from .sql.type_api import Variant  # noqa
index 103225e2a361bc5aecd63ee9466dd7403f82a46e..13bcc37e719d3afe6df7c864ea66e04be1983e62 100644 (file)
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from .compat import (
-    callable,
-    cmp,
-    reduce,
-    threading,
-    py3k,
-    py33,
-    py36,
-    py2k,
-    jython,
-    pypy,
-    cpython,
-    win32,
-    pickle,
-    dottedgetter,
-    parse_qsl,
-    namedtuple,
-    next,
-    reraise,
-    raise_from_cause,
-    text_type,
-    safe_kwarg,
-    string_types,
-    int_types,
-    binary_type,
-    nested,
-    quote_plus,
-    with_metaclass,
-    print_,
-    itertools_filterfalse,
-    u,
-    ue,
-    b,
-    unquote_plus,
-    unquote,
-    b64decode,
-    b64encode,
-    byte_buffer,
-    itertools_filter,
-    iterbytes,
-    StringIO,
-    inspect_getargspec,
-    zip_longest,
-)
 
-from ._collections import (
-    KeyedTuple,
-    ImmutableContainer,
-    immutabledict,
-    Properties,
-    OrderedProperties,
-    ImmutableProperties,
-    OrderedDict,
-    OrderedSet,
-    IdentitySet,
-    OrderedIdentitySet,
-    column_set,
-    column_dict,
-    ordered_column_set,
-    populate_column_dict,
-    unique_list,
-    UniqueAppender,
-    PopulateDict,
-    EMPTY_SET,
-    to_list,
-    to_set,
-    to_column_set,
-    update_copy,
-    flatten_iterator,
-    has_intersection,
-    LRUCache,
-    ScopedRegistry,
-    ThreadLocalRegistry,
-    WeakSequence,
-    coerce_generator_arg,
-    lightweight_named_tuple,
-    collections_abc,
-    has_dupes,
-)
+from collections import defaultdict  # noqa
+from contextlib import contextmanager  # noqa
+from functools import partial  # noqa
+from functools import update_wrapper  # noqa
 
-from .langhelpers import (
-    iterate_attributes,
-    class_hierarchy,
-    portable_instancemethod,
-    unbound_method_to_callable,
-    getargspec_init,
-    format_argspec_init,
-    format_argspec_plus,
-    get_func_kwargs,
-    get_cls_kwargs,
-    decorator,
-    as_interface,
-    memoized_property,
-    memoized_instancemethod,
-    md5_hex,
-    group_expirable_memoized_property,
-    dependencies,
-    decode_slice,
-    monkeypatch_proxied_specials,
-    asbool,
-    bool_or_str,
-    coerce_kw_type,
-    duck_type_collection,
-    assert_arg_type,
-    symbol,
-    dictlike_iteritems,
-    classproperty,
-    set_creation_order,
-    warn_exception,
-    warn,
-    NoneType,
-    constructor_copy,
-    methods_equivalent,
-    chop_traceback,
-    asint,
-    generic_repr,
-    counter,
-    PluginLoader,
-    hybridproperty,
-    hybridmethod,
-    safe_reraise,
-    quoted_token_parser,
-    get_callable_argspec,
-    only_once,
-    attrsetter,
-    ellipses_string,
-    warn_limited,
-    map_bits,
-    MemoizedSlots,
-    EnsureKWArgType,
-    wrap_callable,
-)
+from ._collections import coerce_generator_arg  # noqa
+from ._collections import collections_abc  # noqa
+from ._collections import column_dict  # noqa
+from ._collections import column_set  # noqa
+from ._collections import EMPTY_SET  # noqa
+from ._collections import flatten_iterator  # noqa
+from ._collections import has_dupes  # noqa
+from ._collections import has_intersection  # noqa
+from ._collections import IdentitySet  # noqa
+from ._collections import ImmutableContainer  # noqa
+from ._collections import immutabledict  # noqa
+from ._collections import ImmutableProperties  # noqa
+from ._collections import KeyedTuple  # noqa
+from ._collections import lightweight_named_tuple  # noqa
+from ._collections import LRUCache  # noqa
+from ._collections import ordered_column_set  # noqa
+from ._collections import OrderedDict  # noqa
+from ._collections import OrderedIdentitySet  # noqa
+from ._collections import OrderedProperties  # noqa
+from ._collections import OrderedSet  # noqa
+from ._collections import populate_column_dict  # noqa
+from ._collections import PopulateDict  # noqa
+from ._collections import Properties  # noqa
+from ._collections import ScopedRegistry  # noqa
+from ._collections import ThreadLocalRegistry  # noqa
+from ._collections import to_column_set  # noqa
+from ._collections import to_list  # noqa
+from ._collections import to_set  # noqa
+from ._collections import unique_list  # noqa
+from ._collections import UniqueAppender  # noqa
+from ._collections import update_copy  # noqa
+from ._collections import WeakSequence  # noqa
+from .compat import b  # noqa
+from .compat import b64decode  # noqa
+from .compat import b64encode  # noqa
+from .compat import binary_type  # noqa
+from .compat import byte_buffer  # noqa
+from .compat import callable  # noqa
+from .compat import cmp  # noqa
+from .compat import cpython  # noqa
+from .compat import dottedgetter  # noqa
+from .compat import inspect_getargspec  # noqa
+from .compat import int_types  # noqa
+from .compat import iterbytes  # noqa
+from .compat import itertools_filter  # noqa
+from .compat import itertools_filterfalse  # noqa
+from .compat import jython  # noqa
+from .compat import namedtuple  # noqa
+from .compat import nested  # noqa
+from .compat import next  # noqa
+from .compat import parse_qsl  # noqa
+from .compat import pickle  # noqa
+from .compat import print_  # noqa
+from .compat import py2k  # noqa
+from .compat import py33  # noqa
+from .compat import py36  # noqa
+from .compat import py3k  # noqa
+from .compat import pypy  # noqa
+from .compat import quote_plus  # noqa
+from .compat import raise_from_cause  # noqa
+from .compat import reduce  # noqa
+from .compat import reraise  # noqa
+from .compat import safe_kwarg  # noqa
+from .compat import string_types  # noqa
+from .compat import StringIO  # noqa
+from .compat import text_type  # noqa
+from .compat import threading  # noqa
+from .compat import u  # noqa
+from .compat import ue  # noqa
+from .compat import unquote  # noqa
+from .compat import unquote_plus  # noqa
+from .compat import win32  # noqa
+from .compat import with_metaclass  # noqa
+from .compat import zip_longest  # noqa
+from .deprecations import deprecated  # noqa
+from .deprecations import inject_docstring_text  # noqa
+from .deprecations import pending_deprecation  # noqa
+from .deprecations import warn_deprecated  # noqa
+from .deprecations import warn_pending_deprecation  # noqa
+from .langhelpers import as_interface  # noqa
+from .langhelpers import asbool  # noqa
+from .langhelpers import asint  # noqa
+from .langhelpers import assert_arg_type  # noqa
+from .langhelpers import attrsetter  # noqa
+from .langhelpers import bool_or_str  # noqa
+from .langhelpers import chop_traceback  # noqa
+from .langhelpers import class_hierarchy  # noqa
+from .langhelpers import classproperty  # noqa
+from .langhelpers import coerce_kw_type  # noqa
+from .langhelpers import constructor_copy  # noqa
+from .langhelpers import counter  # noqa
+from .langhelpers import decode_slice  # noqa
+from .langhelpers import decorator  # noqa
+from .langhelpers import dependencies  # noqa
+from .langhelpers import dictlike_iteritems  # noqa
+from .langhelpers import duck_type_collection  # noqa
+from .langhelpers import ellipses_string  # noqa
+from .langhelpers import EnsureKWArgType  # noqa
+from .langhelpers import format_argspec_init  # noqa
+from .langhelpers import format_argspec_plus  # noqa
+from .langhelpers import generic_repr  # noqa
+from .langhelpers import get_callable_argspec  # noqa
+from .langhelpers import get_cls_kwargs  # noqa
+from .langhelpers import get_func_kwargs  # noqa
+from .langhelpers import getargspec_init  # noqa
+from .langhelpers import group_expirable_memoized_property  # noqa
+from .langhelpers import hybridmethod  # noqa
+from .langhelpers import hybridproperty  # noqa
+from .langhelpers import iterate_attributes  # noqa
+from .langhelpers import map_bits  # noqa
+from .langhelpers import md5_hex  # noqa
+from .langhelpers import memoized_instancemethod  # noqa
+from .langhelpers import memoized_property  # noqa
+from .langhelpers import MemoizedSlots  # noqa
+from .langhelpers import methods_equivalent  # noqa
+from .langhelpers import monkeypatch_proxied_specials  # noqa
+from .langhelpers import NoneType  # noqa
+from .langhelpers import only_once  # noqa
+from .langhelpers import PluginLoader  # noqa
+from .langhelpers import portable_instancemethod  # noqa
+from .langhelpers import quoted_token_parser  # noqa
+from .langhelpers import safe_reraise  # noqa
+from .langhelpers import set_creation_order  # noqa
+from .langhelpers import symbol  # noqa
+from .langhelpers import unbound_method_to_callable  # noqa
+from .langhelpers import warn  # noqa
+from .langhelpers import warn_exception  # noqa
+from .langhelpers import warn_limited  # noqa
+from .langhelpers import wrap_callable  # noqa
 
-from .deprecations import (
-    warn_deprecated,
-    warn_pending_deprecation,
-    deprecated,
-    pending_deprecation,
-    inject_docstring_text,
-)
 
 # things that used to be not always available,
 # but are now as of current support Python versions
-from collections import defaultdict
-from functools import partial
-from functools import update_wrapper
-from contextlib import contextmanager
index 67be0e6bfbb036475f1b52b31e76979df15567ee..13575d12da8c9b0ad87772b1195f4c21c773ce87 100644 (file)
@@ -8,17 +8,17 @@
 """Collection classes and helpers."""
 
 from __future__ import absolute_import
-import weakref
+
 import operator
-from .compat import (
-    threading,
-    itertools_filterfalse,
-    string_types,
-    binary_types,
-    collections_abc,
-)
-from . import py2k
 import types
+import weakref
+
+from .compat import binary_types
+from .compat import collections_abc
+from .compat import itertools_filterfalse
+from .compat import py2k
+from .compat import string_types
+from .compat import threading
 
 
 EMPTY_SET = frozenset()
@@ -196,8 +196,8 @@ class Properties(object):
     def __add__(self, other):
         return list(self) + list(other)
 
-    def __setitem__(self, key, object):
-        self._data[key] = object
+    def __setitem__(self, key, obj):
+        self._data[key] = obj
 
     def __getitem__(self, key):
         return self._data[key]
@@ -339,7 +339,7 @@ class OrderedDict(dict):
         def iteritems(self):
             return iter(self.items())
 
-    def __setitem__(self, key, object):
+    def __setitem__(self, key, obj):
         if key not in self:
             try:
                 self._list.append(key)
@@ -347,7 +347,7 @@ class OrderedDict(dict):
                 # work around Python pickle loads() with
                 # dict subclass (seems to ignore __setstate__?)
                 self._list = [key]
-        dict.__setitem__(self, key, object)
+        dict.__setitem__(self, key, obj)
 
     def __delitem__(self, key):
         dict.__delitem__(self, key)
@@ -822,7 +822,7 @@ def to_list(x, default=None):
 
 
 def has_intersection(set_, iterable):
-    """return True if any items of set_ are present in iterable.
+    r"""return True if any items of set\_ are present in iterable.
 
     Goes through special effort to ensure __hash__ is not called
     on items in iterable that don't support it.
index 553624b49b55c0e81a463f401b3a71c9821c8f65..7963eebb61f30df032c417d631dcabd304a80b78 100644 (file)
@@ -9,10 +9,11 @@
 
 import collections
 import contextlib
-import sys
 import operator
+import sys
 import time
 
+
 py36 = sys.version_info >= (3, 6)
 py33 = sys.version_info >= (3, 3)
 py35 = sys.version_info >= (3, 5)
@@ -28,7 +29,7 @@ cpython = not pypy and not jython  # TODO: something better for this ?
 contextmanager = contextlib.contextmanager
 dottedgetter = operator.attrgetter
 namedtuple = collections.namedtuple
-next = next
+next = next  # noqa
 
 ArgSpec = collections.namedtuple(
     "ArgSpec", ["args", "varargs", "keywords", "defaults"]
@@ -37,12 +38,12 @@ ArgSpec = collections.namedtuple(
 try:
     import threading
 except ImportError:
-    import dummy_threading as threading
+    import dummy_threading as threading  # noqa
 
 
 # work around http://bugs.python.org/issue2646
 if py265:
-    safe_kwarg = lambda arg: arg
+    safe_kwarg = lambda arg: arg  # noqa
 else:
     safe_kwarg = str
 
@@ -112,41 +113,44 @@ if py3k:
         return s
 
     if py32:
-        callable = callable
+        callable = callable  # noqa
     else:
 
-        def callable(fn):
+        def callable(fn):  # noqa
             return hasattr(fn, "__call__")
 
 
 else:
     import base64
-    import ConfigParser as configparser
+    import ConfigParser as configparser  # noqa
     import itertools
 
-    from StringIO import StringIO
-    from cStringIO import StringIO as byte_buffer
-    from inspect import getargspec as inspect_getfullargspec
-    from itertools import izip_longest as zip_longest
-    from urllib import quote_plus, unquote_plus, quote, unquote
-    from urlparse import parse_qsl
+    from StringIO import StringIO  # noqa
+    from cStringIO import StringIO as byte_buffer  # noqa
+    from inspect import getargspec as inspect_getfullargspec  # noqa
+    from itertools import izip_longest as zip_longest  # noqa
+    from urllib import quote  # noqa
+    from urllib import quote_plus  # noqa
+    from urllib import unquote  # noqa
+    from urllib import unquote_plus  # noqa
+    from urlparse import parse_qsl  # noqa
 
     try:
         import cPickle as pickle
     except ImportError:
-        import pickle
+        import pickle  # noqa
 
-    string_types = (basestring,)
+    string_types = (basestring,)  # noqa
     binary_types = (bytes,)
     binary_type = str
-    text_type = unicode
-    int_types = int, long
+    text_type = unicode  # noqa
+    int_types = int, long  # noqa
 
     inspect_getargspec = inspect_getfullargspec
 
-    callable = callable
-    cmp = cmp
-    reduce = reduce
+    callable = callable  # noqa
+    cmp = cmp  # noqa
+    reduce = reduce  # noqa
 
     b64encode = base64.b64encode
     b64decode = base64.b64decode
@@ -177,7 +181,7 @@ else:
         if fp is None:
             return
         for arg in enumerate(args):
-            if not isinstance(arg, basestring):
+            if not isinstance(arg, basestring):  # noqa
                 arg = str(arg)
             fp.write(arg)
 
@@ -186,10 +190,10 @@ else:
         # strings - we only use u() with
         # literal source strings, and all our source files with non-ascii
         # in them (all are tests) are utf-8 encoded.
-        return unicode(s, "utf-8")
+        return unicode(s, "utf-8")  # noqa
 
     def ue(s):
-        return unicode(s, "unicode_escape")
+        return unicode(s, "unicode_escape")  # noqa
 
     # not as nice as that of Py3K, but at least preserves
     # the code line where the issue occurred
@@ -271,7 +275,7 @@ if py35:
 
 
 else:
-    from inspect import formatargspec as inspect_formatargspec
+    from inspect import formatargspec as inspect_formatargspec  # noqa
 
 
 if win32 or jython:
@@ -284,7 +288,7 @@ else:
 if py33:
     import collections.abc as collections_abc
 else:
-    import collections as collections_abc
+    import collections as collections_abc  # noqa
 
 
 @contextlib.contextmanager
@@ -299,22 +303,22 @@ def nested(*managers):
     """
 
     exits = []
-    vars = []
+    vars_ = []
     exc = (None, None, None)
     try:
         for mgr in managers:
-            exit = mgr.__exit__
+            exit_ = mgr.__exit__
             enter = mgr.__enter__
-            vars.append(enter())
-            exits.append(exit)
-        yield vars
+            vars_.append(enter())
+            exits.append(exit_)
+        yield vars_
     except:
         exc = sys.exc_info()
     finally:
         while exits:
-            exit = exits.pop()
+            exit_ = exits.pop()  # noqa
             try:
-                if exit(*exc):
+                if exit_(*exc):
                     exc = (None, None, None)
             except:
                 exc = sys.exc_info()
index e6612f075df8eb994220badf6023b7326a2dc3e5..945323530b2443818316239badceda3a775be6fd 100644 (file)
@@ -8,10 +8,12 @@
 """Helpers related to deprecation of functions, methods, classes, other
 functionality."""
 
-from .. import exc
-import warnings
 import re
+import textwrap
+import warnings
+
 from .langhelpers import decorator
+from .. import exc
 
 
 def warn_deprecated(msg, stacklevel=3):
@@ -127,9 +129,6 @@ def _decorate_with_warning(func, wtype, message, docstring_header=None):
     return decorated
 
 
-import textwrap
-
-
 def _dedent_docstring(text):
     split_text = text.split("\n", 1)
     if len(split_text) == 1:
index 6a286998b4673ea01f15f0695258ac76de071b48..49b5eb87fc955620ee6f52e3b01462b9e66a181f 100644 (file)
@@ -9,6 +9,8 @@
 modules, classes, hierarchies, attributes, functions, and methods.
 
 """
+from functools import update_wrapper
+import hashlib
 import inspect
 import itertools
 import operator
@@ -16,11 +18,10 @@ import re
 import sys
 import types
 import warnings
-from functools import update_wrapper
-from .. import exc
-import hashlib
-from . import compat
+
 from . import _collections
+from . import compat
+from .. import exc
 
 
 def md5_hex(x):
@@ -857,7 +858,10 @@ def memoized_instancemethod(fn):
 
     def oneshot(self, *args, **kw):
         result = fn(self, *args, **kw)
-        memo = lambda *a, **kw: result
+
+        def memo(*a, **kw):
+            return result
+
         memo.__name__ = fn.__name__
         memo.__doc__ = fn.__doc__
         self.__dict__[fn.__name__] = memo
@@ -914,7 +918,10 @@ class MemoizedSlots(object):
 
             def oneshot(*args, **kw):
                 result = fn(*args, **kw)
-                memo = lambda *a, **kw: result
+
+                def memo(*a, **kw):
+                    return result
+
                 memo.__name__ = fn.__name__
                 memo.__doc__ = fn.__doc__
                 setattr(self, key, memo)
@@ -928,8 +935,6 @@ class MemoizedSlots(object):
 
 def dependency_for(modulename, add_to_all=False):
     def decorate(obj):
-        # TODO: would be nice to improve on this import silliness,
-        # unfortunately importlib doesn't work that great either
         tokens = modulename.split(".")
         mod = compat.import_(
             ".".join(tokens[0:-1]), globals(), locals(), [tokens[-1]]
@@ -1461,7 +1466,7 @@ def attrsetter(attrname):
 
 
 class EnsureKWArgType(type):
-    """Apply translation of functions to accept **kw arguments if they
+    r"""Apply translation of functions to accept \**kw arguments if they
     don't already.
 
     """
index 5e56e855ae7d834822674420c811dc731ab1e89d..bb5df99e9e0c897f5a98398fa7292116ba08cf7c 100644 (file)
@@ -20,6 +20,7 @@ condition.
 
 from collections import deque
 from time import time as _time
+
 from .compat import threading
 
 
index 95391c31b96218f3ff86542731b73f596cb22aa3..3cc5ef04fee97baf210d246d403fbb900b4d58cd 100644 (file)
@@ -7,8 +7,9 @@
 
 """Topological sorting algorithms."""
 
-from ..exc import CircularDependencyError
 from .. import util
+from ..exc import CircularDependencyError
+
 
 __all__ = ["sort", "sort_as_subsets", "find_cycles"]
 
index 10accde90f9e288993c7565b710e5cae9e157331..1e4033be4b4f7d3703364c317c7f84d5558be7f9 100644 (file)
@@ -10,10 +10,12 @@ running a kill of all detected sessions does not seem to release the
 database in process.
 
 """
-from sqlalchemy.testing import provision
 import logging
 import sys
 
+from sqlalchemy.testing import provision
+
+
 logging.basicConfig()
 logging.getLogger(provision.__name__).setLevel(logging.INFO)
 
index 5c9d4e4f0d7197d035df88f311b71abe852bc4f0..0f5f9f4898de3033bdbb294a6dec71f235907ade 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,16 +1,19 @@
-import os
-import platform
-import re
-import sys
 from distutils.command.build_ext import build_ext
 from distutils.errors import CCompilerError
 from distutils.errors import DistutilsExecError
 from distutils.errors import DistutilsPlatformError
-from setuptools import Distribution as _Distribution, Extension
-from setuptools import setup
+import os
+import platform
+import re
+import sys
+
+from setuptools import Distribution as _Distribution
+from setuptools import Extension
 from setuptools import find_packages
+from setuptools import setup
 from setuptools.command.test import test as TestCommand
 
+
 cmdclass = {}
 if sys.version_info < (2, 7):
     raise Exception("SQLAlchemy requires Python 2.7 or higher.")
index fe5c4d00bc7e5623c550c804625f635a43c32cd7..f5d548ad29e88f0f21989ae0f6472060f58bf882 100755 (executable)
@@ -6,9 +6,11 @@ This script is a front-end to "nosetests" which
 installs SQLAlchemy's testing plugin into the local environment.
 
 """
+import os
 import sys
+
 import nose
-import os
+
 
 if not sys.flags.no_user_site:
     sys.path.insert(
@@ -16,6 +18,7 @@ if not sys.flags.no_user_site:
         os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib')
     )
 
+
 # use bootstrapping so that test plugins are loaded
 # without touching the main library before coverage starts
 bootstrap_file = os.path.join(
@@ -29,5 +32,5 @@ with open(bootstrap_file) as f:
     exec(code, globals(), locals())
 
 
-from noseplugin import NoseSQLAlchemy
+from noseplugin import NoseSQLAlchemy  # noqa
 nose.main(addplugins=[NoseSQLAlchemy()])
index e0f308814cdcdeac73833ebccf0a1ad8028004a7..623efb9a04be0ed2d0f2cfd11746638cdb799de9 100644 (file)
@@ -1,6 +1,14 @@
+from sqlalchemy import Column
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy.engine import default
-from sqlalchemy.testing import fixtures, AssertsExecutionResults, profiling
-from sqlalchemy import MetaData, Table, Column, Integer, String, select
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import profiling
+
 
 t1 = t2 = None
 
index a56fcd409af5c8bc8eb8afda51e143cf74a85d36..0915244f74347222f3262ccd774f248371b9f1fb 100644 (file)
@@ -1,35 +1,37 @@
-from sqlalchemy.testing import eq_
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    clear_mappers,
-    sessionmaker,
-    aliased,
-    Session,
-    subqueryload,
-)
-from sqlalchemy.orm.mapper import _mapper_registry
-from sqlalchemy.orm.session import _sessions
-from sqlalchemy import testing
-from sqlalchemy.testing import engines
-from sqlalchemy import MetaData, Integer, String, ForeignKey, Unicode, select
-import sqlalchemy as sa
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.sql import column
-from sqlalchemy.processors import (
-    to_decimal_processor_factory,
-    to_unicode_processor_factory,
-)
-from sqlalchemy.testing.util import gc_collect
 import decimal
 import gc
-from sqlalchemy.testing import fixtures
-from sqlalchemy import util
-import weakref
 import itertools
-
 import multiprocessing
+import weakref
+
+import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy import Unicode
+from sqlalchemy import util
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm.mapper import _mapper_registry
+from sqlalchemy.orm.session import _sessions
+from sqlalchemy.processors import to_decimal_processor_factory
+from sqlalchemy.processors import to_unicode_processor_factory
+from sqlalchemy.sql import column
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import gc_collect
 
 
 class A(fixtures.ComparableEntity):
index fc546de40e727edc28ac9fcf7c6c0a08d550396c..2727f2d0a2d6a44ec41de3514de765e224ccbb26 100644 (file)
@@ -1,22 +1,23 @@
-from sqlalchemy import Integer, String, ForeignKey
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    sessionmaker,
-    Session,
-    defer,
-    joinedload,
-    defaultload,
-    selectinload,
-    Load,
-    configure_mappers,
-    Bundle,
-)
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import profiling
+from sqlalchemy.orm import Bundle
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import defaultload
+from sqlalchemy.orm import defer
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import Load
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import selectinload
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
 from sqlalchemy.testing import fixtures
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy import inspect
+from sqlalchemy.testing import profiling
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class MergeTest(fixtures.MappedTest):
index af9669294d411c9fe4bb9f2c4198e0e5bd061297..ece619fb5f208eed34ce19c8f693e5eebe695a65 100644 (file)
@@ -1,6 +1,9 @@
-from sqlalchemy.testing import fixtures, AssertsExecutionResults, profiling
-from sqlalchemy.pool import QueuePool
 from sqlalchemy import pool as pool_module
+from sqlalchemy.pool import QueuePool
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import profiling
+
 
 pool = None
 
index ab92ee94d9192412e73ba250ee14bf21d6c26265..8085d5e23ac83781d38e2d38132ef8b4dcba77b7 100644 (file)
@@ -1,18 +1,20 @@
-from sqlalchemy import (
-    MetaData,
-    Table,
-    Column,
-    String,
-    Unicode,
-    Integer,
-    create_engine,
-)
-from sqlalchemy.testing import fixtures, AssertsExecutionResults, profiling
+import sys
+
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
+from sqlalchemy import Unicode
+from sqlalchemy.engine.result import RowProxy
+from sqlalchemy.testing import AssertsExecutionResults
 from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import profiling
 from sqlalchemy.util import u
-from sqlalchemy.engine.result import RowProxy
-import sys
+
 
 NUM_FIELDS = 10
 NUM_RECORDS = 1000
index 9ef824cf65444fc48ca35b2c194104c4ad0d2d15..abe9943927506fe5faf2c83a153a3722a3b07413 100644 (file)
@@ -1,30 +1,30 @@
 from __future__ import unicode_literals
 
+import datetime
+
+from sqlalchemy import and_
+from sqlalchemy import Column
+from sqlalchemy import Date
+from sqlalchemy import DateTime
+from sqlalchemy import Float
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import join
+from sqlalchemy import outerjoin
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import Table
+from sqlalchemy import Time
+from sqlalchemy import Unicode
+from sqlalchemy.testing import replay_fixture
+
+
 """Benchmark for SQLAlchemy.
 
 An adaptation of Robert Brewers' ZooMark speed tests. """
 
 
-import datetime
-from sqlalchemy import (
-    Table,
-    Column,
-    Integer,
-    Unicode,
-    Date,
-    DateTime,
-    Time,
-    Float,
-    Sequence,
-    ForeignKey,
-    select,
-    join,
-    and_,
-    outerjoin,
-    func,
-)
-from sqlalchemy.testing import replay_fixture
-
 ITERATIONS = 1
 
 
index 19ef5b74ab45077e4675234a84635a1b0d6ea0ad..74b559ae95bb597661b48322b4973fc20fe83d9e 100644 (file)
@@ -1,29 +1,29 @@
 from __future__ import unicode_literals
 
+import datetime
+
+from sqlalchemy import and_
+from sqlalchemy import Column
+from sqlalchemy import Date
+from sqlalchemy import DateTime
+from sqlalchemy import Float
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import Table
+from sqlalchemy import Time
+from sqlalchemy import Unicode
+from sqlalchemy.orm import mapper
+from sqlalchemy.testing import replay_fixture
+
+
 """Benchmark for SQLAlchemy.
 
 An adaptation of Robert Brewers' ZooMark speed tests. """
 
 
-import datetime
-from sqlalchemy import (
-    Table,
-    Column,
-    Integer,
-    Unicode,
-    Date,
-    DateTime,
-    Time,
-    Float,
-    Sequence,
-    ForeignKey,
-    select,
-    and_,
-    func,
-)
-from sqlalchemy.orm import mapper
-from sqlalchemy.testing import replay_fixture
-
 ITERATIONS = 1
 
 Zoo = Animal = session = None
@@ -360,9 +360,8 @@ class ZooMarkTest(replay_fixture.ReplayFixtureTest):
                     list(
                         self.session.query(Zoo).filter(
                             and_(
-                                Zoo.Founded != None,  # noqa
-                                Zoo.Founded < func.now(),
-                            )
+                                Zoo.Founded != None, Zoo.Founded < func.now()
+                            )  # noqa
                         )
                     )
                 )
index 3376068f45bbbbdb8d2fbfc22728278d44f8f9a7..7af7fdc7111cd641c05901dd373f5a60326d2cd2 100644 (file)
@@ -1,8 +1,9 @@
-from sqlalchemy.util import topological
-from sqlalchemy.testing import assert_raises, eq_
-from sqlalchemy.testing.util import conforms_partial_ordering
 from sqlalchemy import exc
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.util import conforms_partial_ordering
+from sqlalchemy.util import topological
 
 
 class DependencySortTest(fixtures.TestBase):
index 5cf5d89efe0313d3694cbb6ac82af228cf2b034c..3103b5f066b6cdc44b49ae489dfba7527d70812e 100644 (file)
@@ -1,17 +1,17 @@
 """Test event registration and listening."""
 
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    is_,
-    is_not_,
-)
-from sqlalchemy import event, exc
+from sqlalchemy import event
+from sqlalchemy import exc
+from sqlalchemy import testing
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
 from sqlalchemy.testing.util import gc_collect
-from sqlalchemy.testing.mock import Mock, call
-from sqlalchemy import testing
 
 
 class EventsTest(fixtures.TestBase):
index 2ace55e915576476385ef9b11b473539848bdc25..58943902ce3aa3a14b690f99cfc7756f92adcaa0 100644 (file)
@@ -4,10 +4,11 @@
 
 
 from sqlalchemy import exc as sa_exceptions
-from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import eq_
 from sqlalchemy.engine import default
-from sqlalchemy.util import u, compat
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.util import compat
+from sqlalchemy.util import u
 
 
 class Error(Exception):
index 933d72fe949316b7c6955bc33f2ff0cc118dfa94..6c2cd0c08e22383a9e992001094f2fa42491b24b 100644 (file)
@@ -1,8 +1,10 @@
 """test the inspection registry system."""
 
-from sqlalchemy.testing import eq_, assert_raises_message
-from sqlalchemy import exc, util
-from sqlalchemy import inspection, inspect
+from sqlalchemy import exc
+from sqlalchemy import inspect
+from sqlalchemy import inspection
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
 
 
index c409629c5f55788b4b1a4d9fdbad10a61c76a024..b8322db0a9553b17f6ec3261f4e24cca65a33f57 100644 (file)
@@ -1,11 +1,13 @@
 from __future__ import print_function
-from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import config
+
 import doctest
 import logging
-import sys
-import re
 import os
+import re
+import sys
+
+from sqlalchemy.testing import config
+from sqlalchemy.testing import fixtures
 
 
 class DocTest(fixtures.TestBase):
index 88b865b1d77ae15163c60238f150158035716760..20b41101e2cd13f5f1b88bb7c5f6d4a06158ec2c 100644 (file)
@@ -1,15 +1,29 @@
 import copy
+import inspect
 import sys
 
-from sqlalchemy import util, sql, exc, testing
-from sqlalchemy.testing import assert_raises, assert_raises_message, fixtures
-from sqlalchemy.testing import eq_, in_, is_, ne_, fails_if, mock
-from sqlalchemy.testing import expect_warnings
-from sqlalchemy.testing.util import picklers, gc_collect
-from sqlalchemy.util import classproperty, WeakSequence, get_callable_argspec
+from sqlalchemy import exc
+from sqlalchemy import sql
+from sqlalchemy import testing
+from sqlalchemy import util
 from sqlalchemy.sql import column
-from sqlalchemy.util import langhelpers, compat
-import inspect
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fails_if
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import in_
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import mock
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing.util import gc_collect
+from sqlalchemy.testing.util import picklers
+from sqlalchemy.util import classproperty
+from sqlalchemy.util import compat
+from sqlalchemy.util import get_callable_argspec
+from sqlalchemy.util import langhelpers
+from sqlalchemy.util import WeakSequence
 
 
 class _KeyedTupleTest(object):
@@ -714,16 +728,16 @@ class ColumnCollectionTest(testing.AssertsCompiledSQL, fixtures.TestBase):
 class LRUTest(fixtures.TestBase):
     def test_lru(self):
         class item(object):
-            def __init__(self, id):
-                self.id = id
+            def __init__(self, id_):
+                self.id = id_
 
             def __str__(self):
                 return "item id %d" % self.id
 
         lru = util.LRUCache(10, threshold=0.2)
 
-        for id in range(1, 20):
-            lru[id] = item(id)
+        for id_ in range(1, 20):
+            lru[id_] = item(id_)
 
         # first couple of items should be gone
         assert 1 not in lru
index 9b76b4e55349a2ce6f2b62b75622df8d193b7c39..cdabc9785087e41bfb6ef66c4f9ee032b6f64ec8 100755 (executable)
@@ -6,8 +6,9 @@ This script is an extension to py.test which
 installs SQLAlchemy's testing plugin into the local environment.
 
 """
-import sys
 import os
+import sys
+
 
 if not sys.flags.no_user_site:
     # this is needed so that test scenarios like "python setup.py test"
index 03172aeb317d7d1857ea235cea5cc4e4ae2a51e1..9823faa814cc1c7ccd70dbb4f6479fa6fa690d27 100644 (file)
@@ -1,32 +1,34 @@
 # -*- encoding: utf-8
-from sqlalchemy.testing import eq_, is_
+from sqlalchemy import Column
+from sqlalchemy import delete
+from sqlalchemy import extract
+from sqlalchemy import func
+from sqlalchemy import Index
+from sqlalchemy import insert
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import MetaData
+from sqlalchemy import PrimaryKeyConstraint
 from sqlalchemy import schema
-from sqlalchemy.sql import table, column, quoted_name
-from sqlalchemy.dialects import mssql
-from sqlalchemy.dialects.mssql import mxodbc
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
+from sqlalchemy import select
+from sqlalchemy import Sequence
 from sqlalchemy import sql
-from sqlalchemy import (
-    Integer,
-    String,
-    Table,
-    Column,
-    select,
-    MetaData,
-    update,
-    delete,
-    insert,
-    extract,
-    union,
-    func,
-    PrimaryKeyConstraint,
-    UniqueConstraint,
-    Index,
-    Sequence,
-    literal,
-)
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
+from sqlalchemy import union
+from sqlalchemy import UniqueConstraint
+from sqlalchemy import update
+from sqlalchemy.dialects import mssql
 from sqlalchemy.dialects.mssql import base
+from sqlalchemy.dialects.mssql import mxodbc
+from sqlalchemy.sql import column
+from sqlalchemy.sql import quoted_name
+from sqlalchemy.sql import table
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 
 
 class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
@@ -310,7 +312,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
 
         t = table("sometable", column("foo"))
 
-        for expr, compile in [
+        for expr, compiled in [
             (
                 select([literal("x"), literal("y")]),
                 "SELECT 'x' AS anon_1, 'y' AS anon_2",
@@ -322,7 +324,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             ),
             (t.c.foo.in_([None]), "sometable.foo IN (NULL)"),
         ]:
-            self.assert_compile(expr, compile, dialect=mxodbc_dialect)
+            self.assert_compile(expr, compiled, dialect=mxodbc_dialect)
 
     def test_in_with_subqueries(self):
         """Test removal of legacy behavior that converted "x==subquery"
index 40d3894fb82fdcf65025b814aac6b8816cbb3b92..5f46c5377f9177b47b2ca10fbbcf594596306b31 100644 (file)
@@ -1,20 +1,24 @@
 # -*- encoding: utf-8
-from sqlalchemy.testing import eq_, engines
-from sqlalchemy import *
+from sqlalchemy import Column
+from sqlalchemy import engine_from_config
+from sqlalchemy import event
 from sqlalchemy import exc
-from sqlalchemy.dialects.mssql import pyodbc, pymssql, adodbapi
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy.dialects.mssql import adodbapi
+from sqlalchemy.dialects.mssql import base
+from sqlalchemy.dialects.mssql import pymssql
+from sqlalchemy.dialects.mssql import pyodbc
 from sqlalchemy.engine import url
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import assert_warnings
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
 from sqlalchemy.testing import fixtures
-from sqlalchemy import testing
-from sqlalchemy.testing import (
-    assert_raises_message,
-    assert_warnings,
-    expect_warnings,
-)
 from sqlalchemy.testing.mock import Mock
-from sqlalchemy.dialects.mssql import base
-from sqlalchemy import Integer, String, Table, Column
-from sqlalchemy import event
 
 
 class ParseConnectTest(fixtures.TestBase):
index 4c35283b3afb2f0e43d7e04fc913a32cc417dea6..ef8c63d6bcb88620f09ae0271ffb547c6469df2d 100644 (file)
@@ -1,28 +1,31 @@
 # -*- encoding: utf-8
-from sqlalchemy.testing import eq_, engines
-from sqlalchemy.sql import table, column
-from sqlalchemy.databases import mssql
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL, assertions
+from sqlalchemy import and_
+from sqlalchemy import Column
+from sqlalchemy import DDL
+from sqlalchemy import desc
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import or_
+from sqlalchemy import PrimaryKeyConstraint
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.util import ue
 from sqlalchemy import util
-from sqlalchemy.testing.assertsql import CursorSQL, DialectSQL
-from sqlalchemy import (
-    Integer,
-    String,
-    Table,
-    Column,
-    select,
-    MetaData,
-    func,
-    PrimaryKeyConstraint,
-    desc,
-    DDL,
-    ForeignKey,
-    or_,
-    and_,
-)
-from sqlalchemy import event
+from sqlalchemy.databases import mssql
+from sqlalchemy.sql import column
+from sqlalchemy.sql import table
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertsql import CursorSQL
+from sqlalchemy.testing.assertsql import DialectSQL
+from sqlalchemy.util import ue
+
 
 metadata = None
 cattable = None
index 47322ced646e6c9772fbbdfa8326b298924faa98..29df8706805cad559d8c3749c16d9e626498ed50 100644 (file)
@@ -1,14 +1,29 @@
 # -*- encoding: utf-8
-from sqlalchemy.testing import eq_, is_, in_
-from sqlalchemy import *
-from sqlalchemy import types, schema, event
-from sqlalchemy.databases import mssql
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL, ComparesTables
+from sqlalchemy import Column
+from sqlalchemy import DDL
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import Index
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import PrimaryKeyConstraint
+from sqlalchemy import schema
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.engine.reflection import Inspector
+from sqlalchemy import types
 from sqlalchemy import util
-from sqlalchemy.dialects.mssql.information_schema import CoerceUnicode, tables
+from sqlalchemy.databases import mssql
 from sqlalchemy.dialects.mssql import base
+from sqlalchemy.dialects.mssql.information_schema import CoerceUnicode
+from sqlalchemy.dialects.mssql.information_schema import tables
+from sqlalchemy.engine.reflection import Inspector
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import ComparesTables
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import in_
+from sqlalchemy.testing import is_
 from sqlalchemy.testing import mock
 
 
index 260d6d0dec3b31f79f9518454bed5468708629c1..356057af16037f3c45a5d32bbadbb611c08bdf13 100644 (file)
@@ -1,48 +1,52 @@
 # -*- encoding: utf-8
-from sqlalchemy.testing import eq_, engines, pickleable, assert_raises_message
-from sqlalchemy.testing import is_, is_not_
+import codecs
 import datetime
+import decimal
 import os
-from sqlalchemy import (
-    Table,
-    Column,
-    MetaData,
-    Float,
-    Integer,
-    String,
-    Boolean,
-    Sequence,
-    Numeric,
-    select,
-    Date,
-    Time,
-    DateTime,
-    DefaultClause,
-    PickleType,
-    text,
-    Text,
-    UnicodeText,
-    LargeBinary,
-)
-from sqlalchemy.dialects.mssql import TIMESTAMP, ROWVERSION
-from sqlalchemy import types, schema
-from sqlalchemy import util
-from sqlalchemy.databases import mssql
-from sqlalchemy.dialects.mssql.base import TIME, _MSDate
-from sqlalchemy.dialects.mssql.base import MS_2005_VERSION, MS_2008_VERSION
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsExecutionResults,
-    ComparesTables,
-)
+
+import sqlalchemy as sa
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import Date
+from sqlalchemy import DateTime
+from sqlalchemy import DefaultClause
+from sqlalchemy import Float
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import LargeBinary
+from sqlalchemy import MetaData
+from sqlalchemy import Numeric
+from sqlalchemy import PickleType
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
+from sqlalchemy import Text
+from sqlalchemy import text
+from sqlalchemy import Time
+from sqlalchemy import types
+from sqlalchemy import UnicodeText
+from sqlalchemy.databases import mssql
+from sqlalchemy.dialects.mssql import ROWVERSION
+from sqlalchemy.dialects.mssql import TIMESTAMP
+from sqlalchemy.dialects.mssql.base import _MSDate
+from sqlalchemy.dialects.mssql.base import MS_2005_VERSION
+from sqlalchemy.dialects.mssql.base import MS_2008_VERSION
+from sqlalchemy.dialects.mssql.base import TIME
+from sqlalchemy.sql import sqltypes
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import ComparesTables
 from sqlalchemy.testing import emits_warning_on
-import decimal
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import pickleable
 from sqlalchemy.util import b
-from sqlalchemy import inspect
-from sqlalchemy.sql import sqltypes
-import sqlalchemy as sa
-import codecs
 
 
 class TimeTypeTest(fixtures.TestBase):
@@ -1068,10 +1072,10 @@ class BinaryTest(fixtures.TestBase):
 
         self._test_round_trip(type_(100), data, expected=paddedstream)
 
-    def _load_stream(self, name, len=3000):
+    def _load_stream(self, name, len_=3000):
         fp = open(
             os.path.join(os.path.dirname(__file__), "..", "..", name), "rb"
         )
-        stream = fp.read(len)
+        stream = fp.read(len_)
         fp.close()
         return stream
index 79dff63a35c42b09adbce0d49d7e637f67a801a4..3b77e95f1dde80a59e242defc0e13a3e8278b627 100644 (file)
@@ -1,55 +1,59 @@
 # coding: utf-8
 
-from sqlalchemy.testing import eq_, assert_raises_message, expect_warnings
-from sqlalchemy import sql, exc, schema, types as sqltypes
-from sqlalchemy import (
-    Table,
-    MetaData,
-    Column,
-    select,
-    String,
-    Index,
-    Integer,
-    ForeignKey,
-    PrimaryKeyConstraint,
-    extract,
-    VARCHAR,
-    NVARCHAR,
-    Unicode,
-    UnicodeText,
-    NUMERIC,
-    DECIMAL,
-    Numeric,
-    Float,
-    FLOAT,
-    TIMESTAMP,
-    DATE,
-    DATETIME,
-    TIME,
-    DateTime,
-    Time,
-    Date,
-    Interval,
-    NCHAR,
-    CHAR,
-    CLOB,
-    TEXT,
-    Boolean,
-    BOOLEAN,
-    LargeBinary,
-    BLOB,
-    SmallInteger,
-    INT,
-    func,
-    cast,
-    literal,
-)
-
-from sqlalchemy.dialects.mysql import insert
+from sqlalchemy import BLOB
+from sqlalchemy import BOOLEAN
+from sqlalchemy import Boolean
+from sqlalchemy import cast
+from sqlalchemy import CHAR
+from sqlalchemy import CLOB
+from sqlalchemy import Column
+from sqlalchemy import DATE
+from sqlalchemy import Date
+from sqlalchemy import DATETIME
+from sqlalchemy import DateTime
+from sqlalchemy import DECIMAL
+from sqlalchemy import exc
+from sqlalchemy import extract
+from sqlalchemy import FLOAT
+from sqlalchemy import Float
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Index
+from sqlalchemy import INT
+from sqlalchemy import Integer
+from sqlalchemy import Interval
+from sqlalchemy import LargeBinary
+from sqlalchemy import literal
+from sqlalchemy import MetaData
+from sqlalchemy import NCHAR
+from sqlalchemy import NUMERIC
+from sqlalchemy import Numeric
+from sqlalchemy import NVARCHAR
+from sqlalchemy import PrimaryKeyConstraint
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import SmallInteger
+from sqlalchemy import sql
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import TEXT
+from sqlalchemy import TIME
+from sqlalchemy import Time
+from sqlalchemy import TIMESTAMP
+from sqlalchemy import types as sqltypes
+from sqlalchemy import Unicode
+from sqlalchemy import UnicodeText
+from sqlalchemy import VARCHAR
 from sqlalchemy.dialects.mysql import base as mysql
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
-from sqlalchemy.sql import table, column
+from sqlalchemy.dialects.mysql import insert
+from sqlalchemy.sql import column
+from sqlalchemy.sql import table
 from sqlalchemy.sql.expression import literal_column
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
 
 
 class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
index ffcea3bd1bba967aaeecbe07fd23ccb6db1b98f5..8d0d60f1b57f2755972edb45700d5f4eea33f5c8 100644 (file)
@@ -1,14 +1,22 @@
 # coding: utf-8
 
-from sqlalchemy.testing import eq_
-from sqlalchemy import *
-from sqlalchemy.engine.url import make_url
-from sqlalchemy.testing import fixtures, expect_warnings
+import datetime
+
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import DateTime
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Table
 from sqlalchemy import testing
+from sqlalchemy.dialects import mysql
+from sqlalchemy.engine.url import make_url
 from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
 from ...engine import test_execute
-import datetime
-from sqlalchemy.dialects import mysql
 
 
 class DialectTest(fixtures.TestBase):
index 197c9d6937b307f8967cac5c56eb0e2ad26b3bb6..3537c3220dcef1edf9dd93b285a7306ff97c3d8f 100644 (file)
@@ -5,12 +5,16 @@ See #4246
 """
 import contextlib
 
-from sqlalchemy import Column, Integer, ForeignKey, update
-from sqlalchemy.orm import relationship, Session, joinedload
+from sqlalchemy import Column
 from sqlalchemy import exc
-
-from sqlalchemy.testing import fixtures
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
 from sqlalchemy import testing
+from sqlalchemy import update
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import fixtures
 
 
 class MySQLForUpdateLockingTest(fixtures.DeclarativeMappedTest):
index 04072d4a9c7369704f3cee1a31719d8bd0df9160..0c6f4792901ab60dae4ba8da183479d6dafd41de 100644 (file)
@@ -1,8 +1,15 @@
-from sqlalchemy.testing.assertions import eq_, assert_raises
-from sqlalchemy.testing import fixtures
-from sqlalchemy import exc, testing
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import exc
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
 from sqlalchemy.dialects.mysql import insert
-from sqlalchemy import Table, Column, Boolean, Integer, String, func
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertions import assert_raises
+from sqlalchemy.testing.assertions import eq_
 
 
 class OnDuplicateTest(fixtures.TablesTest):
@@ -71,9 +78,10 @@ class OnDuplicateTest(fixtures.TablesTest):
             stmt = insert(foos)
             update_condition = foos.c.updated_once == False
 
-            # The following statements show importance of the columns update ordering
-            # as old values being referenced in UPDATE clause are getting replaced one
-            # by one from left to right with their new values.
+            # The following statements show importance of the columns update
+            # ordering as old values being referenced in UPDATE clause are
+            # getting replaced one by one from left to right with their new
+            # values.
             stmt1 = stmt.on_duplicate_key_update(
                 [
                     (
index ecd79257f0e2b19b84121e632e9c43aa567f2513..e492f1e17f2e3da7809bdccfe78e9d964fe6430b 100644 (file)
@@ -1,9 +1,24 @@
 # coding: utf-8
 
-from sqlalchemy.testing import eq_, is_
-from sqlalchemy import *
-from sqlalchemy.testing import fixtures
+from sqlalchemy import all_
+from sqlalchemy import and_
+from sqlalchemy import any_
+from sqlalchemy import Boolean
+from sqlalchemy import cast
+from sqlalchemy import Column
+from sqlalchemy import false
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import or_
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
+from sqlalchemy import true
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 
 
 class IdiosyncrasyTest(fixtures.TestBase):
index 2ad63ec2a6acfeb31f0bf2a87bf3c9bd42eceaa8..c42a3be402c72cb6bda4ec22efb4e740bdf5ae37 100644 (file)
@@ -1,39 +1,41 @@
 # coding: utf-8
 
-from sqlalchemy.testing import eq_, is_
-from sqlalchemy import (
-    Column,
-    Table,
-    DDL,
-    MetaData,
-    TIMESTAMP,
-    DefaultClause,
-    String,
-    Integer,
-    Text,
-    UnicodeText,
-    SmallInteger,
-    NCHAR,
-    LargeBinary,
-    DateTime,
-    select,
-    UniqueConstraint,
-    Unicode,
-    BigInteger,
-    Index,
-    ForeignKey,
-)
-from sqlalchemy.schema import CreateIndex
+import re
+
+from sqlalchemy import BigInteger
+from sqlalchemy import Column
+from sqlalchemy import DateTime
+from sqlalchemy import DDL
+from sqlalchemy import DefaultClause
 from sqlalchemy import event
-from sqlalchemy import sql
 from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import Index
 from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import LargeBinary
+from sqlalchemy import MetaData
+from sqlalchemy import NCHAR
+from sqlalchemy import select
+from sqlalchemy import SmallInteger
+from sqlalchemy import sql
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import Text
+from sqlalchemy import TIMESTAMP
+from sqlalchemy import Unicode
+from sqlalchemy import UnicodeText
+from sqlalchemy import UniqueConstraint
 from sqlalchemy.dialects.mysql import base as mysql
 from sqlalchemy.dialects.mysql import reflection as _reflection
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
-from sqlalchemy import testing
-from sqlalchemy.testing import assert_raises_message, expect_warnings
-import re
+from sqlalchemy.schema import CreateIndex
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 
 
 class TypeReflectionTest(fixtures.TestBase):
@@ -623,7 +625,10 @@ class ReflectionTest(fixtures.TestBase, AssertsCompiledSQL):
                     "nullable": False,
                     "default": None
                     if explicit_defaults_for_timestamp
-                    else "%(current_timestamp)s ON UPDATE %(current_timestamp)s"
+                    else (
+                        "%(current_timestamp)s "
+                        "ON UPDATE %(current_timestamp)s"
+                    )
                     % {"current_timestamp": current_timestamp},
                 },
                 {"name": "s", "nullable": False, "default": current_timestamp},
@@ -634,7 +639,10 @@ class ReflectionTest(fixtures.TestBase, AssertsCompiledSQL):
                     else False,
                     "default": None
                     if explicit_defaults_for_timestamp
-                    else "%(current_timestamp)s ON UPDATE %(current_timestamp)s"
+                    else (
+                        "%(current_timestamp)s "
+                        "ON UPDATE %(current_timestamp)s"
+                    )
                     % {"current_timestamp": current_timestamp},
                 },
                 {
index 07c007c532dc60bd4f5a9520cdd4970c3adfeb9d..ed5bbcb2bebf85f962246ec30318a92e9fb6cc3d 100644 (file)
@@ -1,21 +1,36 @@
 # coding: utf-8
 
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message, is_
-from sqlalchemy import *
-from sqlalchemy import sql, exc, schema
-from sqlalchemy.util import u
-from sqlalchemy import util
-from sqlalchemy.dialects.mysql import base as mysql
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsCompiledSQL,
-    AssertsExecutionResults,
-)
-from sqlalchemy import testing
+from collections import OrderedDict
 import datetime
 import decimal
+
+from sqlalchemy import BOOLEAN
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import DefaultClause
+from sqlalchemy import Enum
+from sqlalchemy import exc
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import sql
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import TIMESTAMP
 from sqlalchemy import types as sqltypes
-from collections import OrderedDict
+from sqlalchemy import UnicodeText
+from sqlalchemy import util
+from sqlalchemy.dialects.mysql import base as mysql
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.util import u
 
 
 class TypesTest(
@@ -1219,14 +1234,12 @@ class EnumSetTest(
         # latin-1 stuff forcing its way in ?
 
         eq_(
-            t2.c.value.type.enums[0:2],
-            [u("réveillé"), u("drôle")],  # u'S’il') # eh ?
-        )
+            t2.c.value.type.enums[0:2], [u("réveillé"), u("drôle")]
+        )  # u'S’il') # eh ?
 
         eq_(
-            t2.c.value2.type.enums[0:2],
-            [u("réveillé"), u("drôle")],  # u'S’il') # eh ?
-        )
+            t2.c.value2.type.enums[0:2], [u("réveillé"), u("drôle")]
+        )  # u'S’il') # eh ?
 
     def test_enum_compile(self):
         e1 = Enum("x", "y", "z", name="somename")
index 2edf5848e9cad63c991449ee222cefae49ad4188..a9c84ba49e79e9428dca35cdccaaf65588a9a1a9 100644 (file)
@@ -1,70 +1,37 @@
 # coding: utf-8
 
 
-from sqlalchemy.testing import eq_
-from sqlalchemy import types as sqltypes, exc, schema
-from sqlalchemy.sql import table, column
 from sqlalchemy import and_
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsExecutionResults,
-    AssertsCompiledSQL,
-)
-from sqlalchemy import testing
-from sqlalchemy import (
-    Integer,
-    Text,
-    LargeBinary,
-    Unicode,
-    UniqueConstraint,
-    Index,
-    MetaData,
-    select,
-    inspect,
-    ForeignKey,
-    String,
-    func,
-    TypeDecorator,
-    bindparam,
-    Numeric,
-    TIMESTAMP,
-    CHAR,
-    text,
-    literal_column,
-    VARCHAR,
-    create_engine,
-    Date,
-    NVARCHAR,
-    ForeignKeyConstraint,
-    Sequence,
-    Float,
-    DateTime,
-    cast,
-    UnicodeText,
-    union,
-    except_,
-    type_coerce,
-    or_,
-    outerjoin,
-    DATE,
-    NCHAR,
-    outparam,
-    PrimaryKeyConstraint,
-    FLOAT,
-)
-from sqlalchemy.util import u, b
-from sqlalchemy import util
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy.testing.engines import testing_engine
-from sqlalchemy.dialects.oracle import cx_oracle, base as oracle
-from sqlalchemy.engine import default
-import decimal
-from sqlalchemy.engine import url
-from sqlalchemy.testing.schema import Table, Column
-import datetime
-import os
+from sqlalchemy import bindparam
+from sqlalchemy import exc
+from sqlalchemy import except_
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Index
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import or_
+from sqlalchemy import outerjoin
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import Sequence
 from sqlalchemy import sql
-from sqlalchemy.testing.mock import Mock
+from sqlalchemy import String
+from sqlalchemy import text
+from sqlalchemy import type_coerce
+from sqlalchemy import TypeDecorator
+from sqlalchemy import union
+from sqlalchemy.dialects.oracle import base as oracle
+from sqlalchemy.dialects.oracle import cx_oracle
+from sqlalchemy.engine import default
+from sqlalchemy.sql import column
+from sqlalchemy.sql import table
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
index cfb90c25f4de7f96f56d67d5f64293a345d87e34..8d0e37188127baf82693b4205c0e4f4d74ca80b3 100644 (file)
@@ -1,34 +1,34 @@
 # coding: utf-8
 
 
-from sqlalchemy.testing import eq_
+from sqlalchemy import bindparam
+from sqlalchemy import create_engine
 from sqlalchemy import exc
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsExecutionResults,
-    AssertsCompiledSQL,
-)
+from sqlalchemy import Float
+from sqlalchemy import Integer
+from sqlalchemy import literal_column
+from sqlalchemy import outparam
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import create_engine
-from sqlalchemy import bindparam, outparam
-from sqlalchemy import (
-    text,
-    Float,
-    Integer,
-    String,
-    select,
-    literal_column,
-    Unicode,
-    UnicodeText,
-    Sequence,
-)
-from sqlalchemy.util import u
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy.dialects.oracle import cx_oracle, base as oracle
+from sqlalchemy import text
+from sqlalchemy import Unicode
+from sqlalchemy import UnicodeText
+from sqlalchemy.dialects.oracle import base as oracle
+from sqlalchemy.dialects.oracle import cx_oracle
 from sqlalchemy.engine import url
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
 from sqlalchemy.testing import mock
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.util import u
 
 
 class DialectTest(fixtures.TestBase):
index a88703ab0ba290c8ecfc3cb00ad25cfca41ed0a0..6c36c0a6bb7f57c41d93c37936ac4f908fdb5ac9 100644 (file)
@@ -1,62 +1,35 @@
 # coding: utf-8
 
 
-from sqlalchemy.testing import eq_, is_
 from sqlalchemy import exc
-from sqlalchemy.sql import table
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
+from sqlalchemy import FLOAT
+from sqlalchemy import ForeignKey
+from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import Index
+from sqlalchemy import inspect
+from sqlalchemy import INTEGER
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Numeric
+from sqlalchemy import PrimaryKeyConstraint
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import (
-    Integer,
-    Text,
-    LargeBinary,
-    Unicode,
-    UniqueConstraint,
-    Index,
-    MetaData,
-    select,
-    inspect,
-    ForeignKey,
-    String,
-    func,
-    TypeDecorator,
-    bindparam,
-    Numeric,
-    TIMESTAMP,
-    CHAR,
-    text,
-    literal_column,
-    VARCHAR,
-    create_engine,
-    Date,
-    NVARCHAR,
-    ForeignKeyConstraint,
-    Sequence,
-    Float,
-    DateTime,
-    cast,
-    UnicodeText,
-    union,
-    except_,
-    type_coerce,
-    or_,
-    outerjoin,
-    DATE,
-    NCHAR,
-    outparam,
-    PrimaryKeyConstraint,
-    FLOAT,
-    INTEGER,
-)
-from sqlalchemy.dialects.oracle.base import (
-    NUMBER,
-    BINARY_DOUBLE,
-    BINARY_FLOAT,
-    DOUBLE_PRECISION,
-)
+from sqlalchemy import text
+from sqlalchemy import Unicode
+from sqlalchemy import UniqueConstraint
+from sqlalchemy.dialects.oracle.base import BINARY_DOUBLE
+from sqlalchemy.dialects.oracle.base import BINARY_FLOAT
+from sqlalchemy.dialects.oracle.base import DOUBLE_PRECISION
+from sqlalchemy.dialects.oracle.base import NUMBER
 from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 from sqlalchemy.testing.engines import testing_engine
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class MultiSchemaTest(fixtures.TestBase, AssertsCompiledSQL):
index 6d93d6501d024f5d69b8348b760fc52b44627a19..476159da197ebf14aa2c40985a344c57d6448147 100644 (file)
@@ -1,73 +1,52 @@
 # coding: utf-8
 
 
-from sqlalchemy.testing import eq_
-from sqlalchemy import types as sqltypes, exc, schema
-from sqlalchemy.sql import table, column
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsExecutionResults,
-    AssertsCompiledSQL,
-)
-from sqlalchemy import testing
-from sqlalchemy import (
-    Integer,
-    Text,
-    LargeBinary,
-    Unicode,
-    UniqueConstraint,
-    Index,
-    MetaData,
-    select,
-    inspect,
-    ForeignKey,
-    String,
-    func,
-    TypeDecorator,
-    bindparam,
-    Numeric,
-    TIMESTAMP,
-    CHAR,
-    text,
-    SmallInteger,
-    literal_column,
-    VARCHAR,
-    create_engine,
-    Date,
-    NVARCHAR,
-    ForeignKeyConstraint,
-    Sequence,
-    Float,
-    DateTime,
-    cast,
-    UnicodeText,
-    union,
-    except_,
-    type_coerce,
-    or_,
-    outerjoin,
-    DATE,
-    NCHAR,
-    outparam,
-    PrimaryKeyConstraint,
-    FLOAT,
-)
-from sqlalchemy.sql.sqltypes import NullType
-from sqlalchemy.util import u, b
-from sqlalchemy import util
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy.testing.engines import testing_engine
-from sqlalchemy.dialects.oracle import cx_oracle, base as oracle
-from sqlalchemy.engine import default
-import decimal
-from sqlalchemy.engine import url
-from sqlalchemy.testing.schema import Table, Column
 import datetime
+import decimal
 import os
-from sqlalchemy import sql
-from sqlalchemy.testing.mock import Mock
-from sqlalchemy.testing import mock
+
+from sqlalchemy import bindparam
+from sqlalchemy import cast
+from sqlalchemy import CHAR
+from sqlalchemy import DATE
+from sqlalchemy import Date
+from sqlalchemy import DateTime
 from sqlalchemy import event
+from sqlalchemy import FLOAT
+from sqlalchemy import Float
+from sqlalchemy import Integer
+from sqlalchemy import LargeBinary
+from sqlalchemy import MetaData
+from sqlalchemy import NCHAR
+from sqlalchemy import Numeric
+from sqlalchemy import NVARCHAR
+from sqlalchemy import select
+from sqlalchemy import SmallInteger
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy import Text
+from sqlalchemy import text
+from sqlalchemy import TIMESTAMP
+from sqlalchemy import TypeDecorator
+from sqlalchemy import types as sqltypes
+from sqlalchemy import Unicode
+from sqlalchemy import UnicodeText
+from sqlalchemy import util
+from sqlalchemy import VARCHAR
+from sqlalchemy.dialects.oracle import base as oracle
+from sqlalchemy.dialects.oracle import cx_oracle
+from sqlalchemy.sql import column
+from sqlalchemy.sql.sqltypes import NullType
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import mock
+from sqlalchemy.testing.engines import testing_engine
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.util import b
+from sqlalchemy.util import u
 
 
 class DialectTypesTest(fixtures.TestBase, AssertsCompiledSQL):
@@ -461,7 +440,8 @@ class TypesTest(fixtures.TestBase):
             [("nan",), ("nan",)],
         )
 
-    # needs https://github.com/oracle/python-cx_Oracle/issues/184#issuecomment-391399292
+    # needs https://github.com/oracle/python-cx_Oracle/
+    # issues/184#issuecomment-391399292
     @testing.provide_metadata
     def _dont_test_numeric_nan_decimal(self):
         m = self.metadata
index 58e421f8ac9d5fe1493759593900fb761eece2a7..a9c9722c9d2ddd7dd09cfe10d86cf6c10d186e43 100644 (file)
@@ -1,45 +1,51 @@
 # coding: utf-8
 
-from sqlalchemy.testing.assertions import (
-    AssertsCompiledSQL,
-    is_,
-    assert_raises,
-    assert_raises_message,
-    expect_warnings,
-)
-from sqlalchemy.testing import engines, fixtures
+from sqlalchemy import and_
+from sqlalchemy import cast
+from sqlalchemy import Column
+from sqlalchemy import delete
+from sqlalchemy import Enum
+from sqlalchemy import exc
+from sqlalchemy import func
+from sqlalchemy import Index
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import null
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy import (
-    Sequence,
-    Table,
-    Column,
-    Integer,
-    update,
-    String,
-    func,
-    MetaData,
-    Enum,
-    Index,
-    and_,
-    delete,
-    select,
-    cast,
-    text,
-    Text,
-    null,
-)
+from sqlalchemy import Text
+from sqlalchemy import text
 from sqlalchemy import types as sqltypes
-from sqlalchemy.dialects.postgresql import ExcludeConstraint, array
-from sqlalchemy import exc, schema
+from sqlalchemy import update
 from sqlalchemy.dialects import postgresql
+from sqlalchemy.dialects.postgresql import aggregate_order_by
+from sqlalchemy.dialects.postgresql import ARRAY as PG_ARRAY
+from sqlalchemy.dialects.postgresql import array
+from sqlalchemy.dialects.postgresql import array_agg as pg_array_agg
+from sqlalchemy.dialects.postgresql import ExcludeConstraint
+from sqlalchemy.dialects.postgresql import insert
 from sqlalchemy.dialects.postgresql import TSRANGE
-from sqlalchemy.orm import mapper, aliased, Session
-from sqlalchemy.sql import table, column, operators, literal_column
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Session
+from sqlalchemy.sql import column
+from sqlalchemy.sql import literal_column
+from sqlalchemy.sql import operators
+from sqlalchemy.sql import table
 from sqlalchemy.sql import util as sql_util
-from sqlalchemy.util import u, OrderedDict
-from sqlalchemy.dialects.postgresql import aggregate_order_by, insert
-from sqlalchemy.dialects.postgresql import array_agg as pg_array_agg
-from sqlalchemy.dialects.postgresql import ARRAY as PG_ARRAY
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertions import assert_raises
+from sqlalchemy.testing.assertions import assert_raises_message
+from sqlalchemy.testing.assertions import AssertsCompiledSQL
+from sqlalchemy.testing.assertions import expect_warnings
+from sqlalchemy.testing.assertions import is_
+from sqlalchemy.util import OrderedDict
+from sqlalchemy.util import u
 
 
 class SequenceTest(fixtures.TestBase, AssertsCompiledSQL):
index 82dd6d3ff62e95b671b05239eff95228854ee0a0..d4e1cddc40434b1c8988a368ba515b804cb711c4 100644 (file)
@@ -1,46 +1,45 @@
 # coding: utf-8
 
-from sqlalchemy.testing.assertions import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    AssertsExecutionResults,
-    AssertsCompiledSQL,
-)
-from sqlalchemy.testing import engines, fixtures
-from sqlalchemy import testing
 import datetime
-from sqlalchemy import (
-    Table,
-    Column,
-    select,
-    MetaData,
-    text,
-    Integer,
-    String,
-    Sequence,
-    Numeric,
-    DateTime,
-    BigInteger,
-    func,
-    extract,
-    SmallInteger,
-    TypeDecorator,
-    literal,
-    cast,
-    bindparam,
-)
-from sqlalchemy import exc, schema
-from sqlalchemy.dialects.postgresql import base as postgresql
 import logging
 import logging.handlers
-from sqlalchemy.testing.mock import Mock
+
+from sqlalchemy import BigInteger
+from sqlalchemy import bindparam
+from sqlalchemy import cast
+from sqlalchemy import Column
+from sqlalchemy import DateTime
+from sqlalchemy import dialects
+from sqlalchemy import exc
+from sqlalchemy import extract
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import MetaData
+from sqlalchemy import Numeric
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import SmallInteger
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import TypeDecorator
+from sqlalchemy.dialects.postgresql import base as postgresql
 from sqlalchemy.engine import engine_from_config
 from sqlalchemy.engine import url
-from sqlalchemy.testing import is_
+from sqlalchemy.testing import engines
 from sqlalchemy.testing import expect_deprecated
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.assertions import assert_raises
+from sqlalchemy.testing.assertions import assert_raises_message
+from sqlalchemy.testing.assertions import AssertsCompiledSQL
+from sqlalchemy.testing.assertions import AssertsExecutionResults
+from sqlalchemy.testing.assertions import eq_
+from sqlalchemy.testing.mock import Mock
 from ...engine import test_execute
-from sqlalchemy import dialects
 
 
 class DialectTest(fixtures.TestBase):
index 4e73c38402d5560f559145551e536fd939b06614..c74f4cbef0faabb29a4230d5a16e5b67a855279f 100644 (file)
@@ -1,11 +1,18 @@
 # coding: utf-8
 
-from sqlalchemy.testing.assertions import eq_, assert_raises
-from sqlalchemy.testing import fixtures
+from sqlalchemy import Column
+from sqlalchemy import exc
+from sqlalchemy import Integer
+from sqlalchemy import schema
+from sqlalchemy import sql
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy import Table, Column, Integer, String
-from sqlalchemy import exc, schema, types as sqltypes, sql
+from sqlalchemy import types as sqltypes
 from sqlalchemy.dialects.postgresql import insert
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertions import assert_raises
+from sqlalchemy.testing.assertions import eq_
 
 
 class OnConflictTest(fixtures.TablesTest):
index 4156dc0f51777d0698ad62d383157e191b9f3b5e..40cd85c79814788b0dc36cfe860c3a4a3b1621b8 100644 (file)
@@ -1,41 +1,40 @@
 # coding: utf-8
 
-from sqlalchemy.testing import (
-    AssertsExecutionResults,
-    eq_,
-    assert_raises_message,
-    AssertsCompiledSQL,
-    expect_warnings,
-    assert_raises,
-)
-from sqlalchemy import (
-    Table,
-    Column,
-    MetaData,
-    Integer,
-    String,
-    bindparam,
-    Sequence,
-    ForeignKey,
-    text,
-    select,
-    func,
-    extract,
-    literal_column,
-    tuple_,
-    DateTime,
-    Time,
-    literal,
-    and_,
-    Date,
-    or_,
-)
-from sqlalchemy.testing import engines, fixtures
-from sqlalchemy.testing.assertsql import DialectSQL, CursorSQL
-from sqlalchemy import testing
+import datetime
+
+from sqlalchemy import and_
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import Date
+from sqlalchemy import DateTime
 from sqlalchemy import exc
+from sqlalchemy import extract
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import or_
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import Time
+from sqlalchemy import tuple_
 from sqlalchemy.dialects import postgresql
-import datetime
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertsql import CursorSQL
+from sqlalchemy.testing.assertsql import DialectSQL
+
 
 matchtable = cattable = None
 
index d9facad6d944144b80299d413441a5f314bc23bc..311835daee045ab380a607e0b597c317a489d93e 100644 (file)
@@ -1,36 +1,36 @@
 # coding: utf-8
 
-from sqlalchemy.engine import reflection
-from sqlalchemy.sql.schema import CheckConstraint
-from sqlalchemy.testing.assertions import (
-    eq_,
-    assert_raises,
-    AssertsExecutionResults,
-)
-from sqlalchemy.testing import fixtures
-from sqlalchemy import testing
-from sqlalchemy import inspect
-from sqlalchemy import (
-    Table,
-    Column,
-    MetaData,
-    Integer,
-    String,
-    PrimaryKeyConstraint,
-    ForeignKey,
-    join,
-    Sequence,
-    UniqueConstraint,
-    Index,
-)
-from sqlalchemy import exc
+import itertools
+from operator import itemgetter
+import re
+
 import sqlalchemy as sa
+from sqlalchemy import Column
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import Index
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import join
+from sqlalchemy import MetaData
+from sqlalchemy import PrimaryKeyConstraint
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import UniqueConstraint
+from sqlalchemy.dialects.postgresql import ARRAY
 from sqlalchemy.dialects.postgresql import base as postgresql
-from sqlalchemy.dialects.postgresql import ARRAY, INTERVAL, INTEGER, TSRANGE
 from sqlalchemy.dialects.postgresql import ExcludeConstraint
-import re
-from operator import itemgetter
-import itertools
+from sqlalchemy.dialects.postgresql import INTEGER
+from sqlalchemy.dialects.postgresql import INTERVAL
+from sqlalchemy.dialects.postgresql import TSRANGE
+from sqlalchemy.engine import reflection
+from sqlalchemy.sql.schema import CheckConstraint
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertions import assert_raises
+from sqlalchemy.testing.assertions import AssertsExecutionResults
+from sqlalchemy.testing.assertions import eq_
 
 
 class ForeignTableReflectionTest(fixtures.TablesTest, AssertsExecutionResults):
index d7ae2139634286109fa950d42fa08108d2b14cef..f20f92251ac7a8824ab5dec1b5a02add2c3070f8 100644 (file)
@@ -1,66 +1,62 @@
 # coding: utf-8
-from sqlalchemy.testing.assertions import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    is_,
-    AssertsExecutionResults,
-    AssertsCompiledSQL,
-    ComparesTables,
-)
-from sqlalchemy.testing import engines, fixtures
-from sqlalchemy import testing
-from sqlalchemy.sql import sqltypes
 import datetime
-from sqlalchemy import (
-    Table,
-    MetaData,
-    Column,
-    Integer,
-    Enum,
-    Float,
-    select,
-    func,
-    DateTime,
-    Numeric,
-    exc,
-    String,
-    cast,
-    REAL,
-    TypeDecorator,
-    Unicode,
-    Text,
-    null,
-    text,
-    column,
-    ARRAY,
-    any_,
-    all_,
-)
-from sqlalchemy.sql import operators
-from sqlalchemy import types
-import sqlalchemy as sa
-from sqlalchemy.dialects import postgresql
-from sqlalchemy.dialects.postgresql import (
-    HSTORE,
-    hstore,
-    array,
-    INT4RANGE,
-    INT8RANGE,
-    NUMRANGE,
-    DATERANGE,
-    TSRANGE,
-    TSTZRANGE,
-    JSON,
-    JSONB,
-)
 import decimal
-from sqlalchemy import util
-from sqlalchemy.testing.util import round_decimal
-from sqlalchemy import inspect
+
+import sqlalchemy as sa
+from sqlalchemy import any_
+from sqlalchemy import ARRAY
+from sqlalchemy import cast
+from sqlalchemy import Column
+from sqlalchemy import column
+from sqlalchemy import DateTime
+from sqlalchemy import Enum
 from sqlalchemy import event
+from sqlalchemy import exc
+from sqlalchemy import Float
+from sqlalchemy import func
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import null
+from sqlalchemy import Numeric
+from sqlalchemy import REAL
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import Text
+from sqlalchemy import text
+from sqlalchemy import TypeDecorator
+from sqlalchemy import types
+from sqlalchemy import Unicode
+from sqlalchemy import util
+from sqlalchemy.dialects import postgresql
+from sqlalchemy.dialects.postgresql import array
+from sqlalchemy.dialects.postgresql import DATERANGE
+from sqlalchemy.dialects.postgresql import HSTORE
+from sqlalchemy.dialects.postgresql import hstore
+from sqlalchemy.dialects.postgresql import INT4RANGE
+from sqlalchemy.dialects.postgresql import INT8RANGE
+from sqlalchemy.dialects.postgresql import JSON
+from sqlalchemy.dialects.postgresql import JSONB
+from sqlalchemy.dialects.postgresql import NUMRANGE
+from sqlalchemy.dialects.postgresql import TSRANGE
+from sqlalchemy.dialects.postgresql import TSTZRANGE
 from sqlalchemy.ext.declarative import declarative_base
 from sqlalchemy.orm import Session
+from sqlalchemy.sql import operators
+from sqlalchemy.sql import sqltypes
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertions import assert_raises
+from sqlalchemy.testing.assertions import assert_raises_message
+from sqlalchemy.testing.assertions import AssertsCompiledSQL
+from sqlalchemy.testing.assertions import AssertsExecutionResults
+from sqlalchemy.testing.assertions import ComparesTables
+from sqlalchemy.testing.assertions import eq_
+from sqlalchemy.testing.assertions import is_
+from sqlalchemy.testing.util import round_decimal
+
 
 tztable = notztable = metadata = table = None
 
@@ -2575,8 +2571,8 @@ class _RangeTypeRoundTrip(fixtures.TablesTest):
             self.tables.data_table.insert(), {"range": self._data_str}
         )
         # select
-        range = self.tables.data_table.c.range
-        data = testing.db.execute(select([range + range])).fetchall()
+        range_ = self.tables.data_table.c.range
+        data = testing.db.execute(select([range_ + range_])).fetchall()
         eq_(data, [(self._data_obj(),)])
 
     def test_intersection_result(self):
@@ -2585,8 +2581,8 @@ class _RangeTypeRoundTrip(fixtures.TablesTest):
             self.tables.data_table.insert(), {"range": self._data_str}
         )
         # select
-        range = self.tables.data_table.c.range
-        data = testing.db.execute(select([range * range])).fetchall()
+        range_ = self.tables.data_table.c.range
+        data = testing.db.execute(select([range_ * range_])).fetchall()
         eq_(data, [(self._data_obj(),)])
 
     def test_difference_result(self):
@@ -2595,8 +2591,8 @@ class _RangeTypeRoundTrip(fixtures.TablesTest):
             self.tables.data_table.insert(), {"range": self._data_str}
         )
         # select
-        range = self.tables.data_table.c.range
-        data = testing.db.execute(select([range - range])).fetchall()
+        range_ = self.tables.data_table.c.range
+        data = testing.db.execute(select([range_ - range_])).fetchall()
         eq_(data, [(self._data_obj().__class__(empty=True),)])
 
 
index c61a258dad87f4310bc8da182276ed811135d593..1e4366eb720f256971bca6c6bbbd281a33be9013 100644 (file)
@@ -1,6 +1,6 @@
+from sqlalchemy import dialects
 from sqlalchemy.testing import fixtures
 from sqlalchemy.testing import is_not_
-from sqlalchemy import dialects
 
 
 class ImportStarTest(fixtures.TestBase):
index 3aac6a5c0581a73940b582081195c99e8a86aacd..f1ce321e3c2eafe1175e2936d8e52b1abf77f7fd 100644 (file)
@@ -1,35 +1,33 @@
-from sqlalchemy.testing import eq_, assert_raises_message
+from sqlalchemy import Column
 from sqlalchemy import exc
+from sqlalchemy import Float
+from sqlalchemy import func
+from sqlalchemy import insert
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import types as sqltypes
+from sqlalchemy import Unicode
+from sqlalchemy import update
+from sqlalchemy import VARCHAR
 from sqlalchemy.databases import firebird
 from sqlalchemy.exc import ProgrammingError
-from sqlalchemy.sql import table, column
-from sqlalchemy import types as sqltypes
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsExecutionResults,
-    AssertsCompiledSQL,
-)
-from sqlalchemy import testing
+from sqlalchemy.sql import column
+from sqlalchemy.sql import table
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
 from sqlalchemy.testing import engines
-from sqlalchemy import (
-    String,
-    VARCHAR,
-    NVARCHAR,
-    Unicode,
-    Integer,
-    func,
-    insert,
-    update,
-    MetaData,
-    select,
-    Table,
-    Column,
-    text,
-    Sequence,
-    Float,
-)
-from sqlalchemy import schema
-from sqlalchemy.testing.mock import Mock, call
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
 
 
 class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults):
index abff52744c91da87fb1425950eaf76a11a2adc35..de8b22b67cd8350231e546b8f66d79661958950d 100644 (file)
@@ -1,6 +1,9 @@
-from sqlalchemy import *
-from sqlalchemy.testing import eq_
+from sqlalchemy import Column
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Table
 from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
 from sqlalchemy.testing.mock import Mock
 
@@ -42,10 +45,13 @@ class MxODBCTest(fixtures.TestBase):
         )
 
         eq_(
+            # fmt: off
             [
                 c[2]
-                for c in dbapi.connect.return_value.cursor.return_value.execute.mock_calls
+                for c in dbapi.connect.return_value.cursor.
+                return_value.execute.mock_calls
             ],
+            # fmt: on
             [
                 {"direct": True},
                 {"direct": True},
@@ -53,5 +59,5 @@ class MxODBCTest(fixtures.TestBase):
                 {"direct": True},
                 {"direct": False},
                 {"direct": True},
-            ],
+            ]
         )
index 5c60c5b5aef855a91cf5563fe1115ae8ada860be..80f1e468abfabf9829f72d2e55370dd7fb290677 100644 (file)
@@ -1,5 +1,5 @@
-from sqlalchemy.testing import eq_
 from sqlalchemy.connectors import pyodbc
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
 
 
index 0c3dd2acd6ee803a00524b01572fdcd636e9b133..c480653b32a89d8e59538a065758bc0dad77fe34 100644 (file)
@@ -1,54 +1,58 @@
 #!coding: utf-8
 
 """SQLite-specific tests."""
-import os
 import datetime
+import os
 
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    is_,
-    expect_warnings,
-)
-from sqlalchemy import (
-    Table,
-    select,
-    bindparam,
-    Column,
-    MetaData,
-    func,
-    extract,
-    ForeignKey,
-    text,
-    DefaultClause,
-    and_,
-    create_engine,
-    UniqueConstraint,
-    Index,
-    PrimaryKeyConstraint,
-    CheckConstraint,
-)
-from sqlalchemy.types import Integer, String, Boolean, DateTime, Date, Time
-from sqlalchemy import types as sqltypes
-from sqlalchemy import event, inspect
-from sqlalchemy.util import u, ue
-from sqlalchemy import exc, sql, schema, pool, util
-from sqlalchemy.dialects.sqlite import (
-    base as sqlite,
-    pysqlite as pysqlite_dialect,
-)
-from sqlalchemy.engine.url import make_url
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsCompiledSQL,
-    AssertsExecutionResults,
-    engines,
-)
+from sqlalchemy import and_
+from sqlalchemy import bindparam
+from sqlalchemy import CheckConstraint
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import DefaultClause
+from sqlalchemy import event
+from sqlalchemy import exc
+from sqlalchemy import extract
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Index
+from sqlalchemy import inspect
+from sqlalchemy import MetaData
+from sqlalchemy import pool
+from sqlalchemy import PrimaryKeyConstraint
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import sql
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.schema import CreateTable, FetchedValue
+from sqlalchemy import text
+from sqlalchemy import types as sqltypes
+from sqlalchemy import UniqueConstraint
+from sqlalchemy import util
+from sqlalchemy.dialects.sqlite import base as sqlite
+from sqlalchemy.dialects.sqlite import pysqlite as pysqlite_dialect
 from sqlalchemy.engine.reflection import Inspector
+from sqlalchemy.engine.url import make_url
+from sqlalchemy.schema import CreateTable
+from sqlalchemy.schema import FetchedValue
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 from sqlalchemy.testing import mock
+from sqlalchemy.types import Boolean
+from sqlalchemy.types import Date
+from sqlalchemy.types import DateTime
+from sqlalchemy.types import Integer
+from sqlalchemy.types import String
+from sqlalchemy.types import Time
+from sqlalchemy.util import u
+from sqlalchemy.util import ue
 
 
 class TestTypes(fixtures.TestBase, AssertsExecutionResults):
index d4e753656861033a3d3e6d974ce8538068c2bf1f..bf58c6fcc36308315758bcfd0e7164c13d43447a 100644 (file)
@@ -1 +1 @@
-from sqlalchemy.testing.suite import *
+from sqlalchemy.testing.suite import *  # noqa
index df2ae784e3e6f2814c53378d9c34a8659bd962bc..38786ab4be3eb4c40f22731eed312f8858bdeba6 100644 (file)
@@ -1,11 +1,10 @@
-from sqlalchemy import extract, select
+from sqlalchemy import extract
+from sqlalchemy import select
 from sqlalchemy import sql
 from sqlalchemy.databases import sybase
-from sqlalchemy.testing import (
-    assert_raises_message,
-    fixtures,
-    AssertsCompiledSQL,
-)
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import fixtures
 
 
 class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
index 862626c40f3fe05ad74aea6731506fdac12bad6e..98d53ee6def562bc5f4c0ecb0828e8d11fc32eab 100644 (file)
@@ -1,15 +1,19 @@
 """tests the "bind" attribute/argument across schema and SQL,
 including the deprecated versions of these arguments"""
 
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy import engine, exc
-from sqlalchemy import MetaData, ThreadLocalMetaData
-from sqlalchemy import Integer, text
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
 import sqlalchemy as sa
+from sqlalchemy import engine
+from sqlalchemy import exc
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
 from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import ThreadLocalMetaData
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class BindTest(fixtures.TestBase):
index 307cb1cf1f9f44fdc424a73cef5884123d6f9ea6..562ed4d68dddbeb83694d8f27d7513c9cbbfba25 100644 (file)
@@ -1,20 +1,24 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy.schema import (
-    DDL,
-    CheckConstraint,
-    AddConstraint,
-    DropConstraint,
-)
-from sqlalchemy import create_engine
-from sqlalchemy import MetaData, Integer, String, event, exc, text
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
 import sqlalchemy as tsa
+from sqlalchemy import create_engine
+from sqlalchemy import event
+from sqlalchemy import exc
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
 from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy.schema import AddConstraint
+from sqlalchemy.schema import CheckConstraint
+from sqlalchemy.schema import DDL
+from sqlalchemy.schema import DropConstraint
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import AssertsCompiledSQL
 from sqlalchemy.testing import engines
-from sqlalchemy.testing import AssertsCompiledSQL, eq_
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
 from sqlalchemy.testing import mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class DDLEventTest(fixtures.TestBase):
@@ -704,9 +708,12 @@ class DDLTest(fixtures.TestBase, AssertsCompiledSQL):
         engine = create_engine(
             testing.db.name + "://", strategy="mock", executor=executor
         )
-        engine.dialect.identifier_preparer = tsa.sql.compiler.IdentifierPreparer(
-            engine.dialect
-        )
+        # fmt: off
+        engine.dialect.identifier_preparer = \
+            tsa.sql.compiler.IdentifierPreparer(
+                engine.dialect
+            )
+        # fmt: on
         return engine
 
     def test_tokens(self):
index 87bf52bdb6027322f0f7c8094d5eaa4a1d0fabc9..d9d10a9a6cac774cb96689e1da80a5c87e62add4 100644 (file)
@@ -1,51 +1,50 @@
 # coding: utf-8
 
-import weakref
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    config,
-    is_,
-    is_not_,
-    le_,
-    expect_warnings,
-)
+from contextlib import contextmanager
 import re
-from sqlalchemy.testing.util import picklers
-from sqlalchemy.testing.util import gc_collect
-from sqlalchemy.interfaces import ConnectionProxy
-from sqlalchemy import (
-    MetaData,
-    Integer,
-    String,
-    INT,
-    VARCHAR,
-    func,
-    bindparam,
-    select,
-    event,
-    TypeDecorator,
-    create_engine,
-    Sequence,
-    LargeBinary,
-)
-from sqlalchemy.sql import column, literal
-from sqlalchemy.testing.schema import Table, Column
+import weakref
+
 import sqlalchemy as tsa
+from sqlalchemy import bindparam
+from sqlalchemy import create_engine
+from sqlalchemy import event
+from sqlalchemy import func
+from sqlalchemy import INT
+from sqlalchemy import Integer
+from sqlalchemy import LargeBinary
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import engines
+from sqlalchemy import TypeDecorator
 from sqlalchemy import util
-from sqlalchemy.testing.engines import testing_engine
-from sqlalchemy.dialects.oracle.zxjdbc import ReturningParam
-from sqlalchemy.engine import result as _result, default
+from sqlalchemy import VARCHAR
+from sqlalchemy.engine import default
 from sqlalchemy.engine.base import Engine
+from sqlalchemy.interfaces import ConnectionProxy
+from sqlalchemy.sql import column
+from sqlalchemy.sql import literal
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import config
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
 from sqlalchemy.testing import fixtures
-from sqlalchemy.testing.mock import Mock, call, patch
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
 from sqlalchemy.testing import mock
-from contextlib import contextmanager
-from sqlalchemy.util import nested
 from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.engines import testing_engine
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.mock import patch
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import gc_collect
+from sqlalchemy.testing.util import picklers
+from sqlalchemy.util import nested
 
 
 users, metadata, users_autoinc = None, None, None
index 4a19ee86f67a98f4016476126e9db67d29d248fc..8190a3fcde44903e3717da04372600721fb23492 100644 (file)
@@ -1,12 +1,15 @@
-from sqlalchemy.testing import eq_, assert_raises_message, eq_regex
-from sqlalchemy import select
+import logging.handlers
+
 import sqlalchemy as tsa
+from sqlalchemy import select
+from sqlalchemy import util
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import engines
-import logging.handlers
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import eq_regex
 from sqlalchemy.testing import fixtures
 from sqlalchemy.testing import mock
 from sqlalchemy.testing.util import lazy_gc
-from sqlalchemy import util
 
 
 class LogParamsTest(fixtures.TestBase):
index 39ad7042bb7cc15f757d505be15ce6c4b6197fc8..7a89188179bdf14030072ffd41dc8c3f8391906e 100644 (file)
@@ -1,14 +1,22 @@
-from sqlalchemy.testing import assert_raises, eq_, is_
-import sqlalchemy.engine.url as url
-from sqlalchemy import create_engine, engine_from_config, exc, pool
-from sqlalchemy.engine.default import DefaultDialect
 import sqlalchemy as tsa
-from sqlalchemy.testing import fixtures
+from sqlalchemy import create_engine
+from sqlalchemy import engine_from_config
+from sqlalchemy import exc
+from sqlalchemy import pool
 from sqlalchemy import testing
-from sqlalchemy.testing.mock import Mock, MagicMock, call
-from sqlalchemy.testing import mock
-from sqlalchemy.dialects import registry
 from sqlalchemy.dialects import plugins
+from sqlalchemy.dialects import registry
+from sqlalchemy.engine.default import DefaultDialect
+import sqlalchemy.engine.url as url
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import mock
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import MagicMock
+from sqlalchemy.testing.mock import Mock
+
 
 dialect = None
 
index 547c265bb41a496d0caea7d78790af11ab69849c..02eb5fc5430791cd25275e5422ac6cff52bf7f0a 100644 (file)
@@ -1,17 +1,28 @@
+import collections
+import random
 import threading
 import time
-from sqlalchemy import pool, select, event
+import weakref
+
 import sqlalchemy as tsa
+from sqlalchemy import event
+from sqlalchemy import pool
+from sqlalchemy import select
 from sqlalchemy import testing
-from sqlalchemy.testing.util import gc_collect, lazy_gc
-from sqlalchemy.testing import eq_, assert_raises, is_not_, is_
-from sqlalchemy.testing.engines import testing_engine
-from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import assert_raises
 from sqlalchemy.testing import assert_raises_message
-import random
-from sqlalchemy.testing.mock import Mock, call, patch, ANY
-import weakref
-import collections
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+from sqlalchemy.testing.engines import testing_engine
+from sqlalchemy.testing.mock import ANY
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.mock import patch
+from sqlalchemy.testing.util import gc_collect
+from sqlalchemy.testing.util import lazy_gc
+
 
 join_timeout = 10
 
index 8da838145becaba595c47f510350ebff7c40f7b1..9bfd8d505d8b51f833da410a0ad27aa20b38328c 100644 (file)
@@ -1,5 +1,6 @@
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import assert_raises_message, eq_
 
 
 class _BooleanProcessorTest(fixtures.TestBase):
index 1ba8bcac24c2166e23055f20fde7f7b3f96fafd8..f6904174b9161ad4d12a60f328cc6cb9adf89dcd 100644 (file)
@@ -1,31 +1,31 @@
-from sqlalchemy.testing import (
-    eq_,
-    ne_,
-    assert_raises,
-    expect_warnings,
-    assert_raises_message,
-)
 import time
-from sqlalchemy import (
-    select,
-    MetaData,
-    Integer,
-    String,
-    create_engine,
-    pool,
-    exc,
-    util,
-)
-from sqlalchemy.testing.schema import Table, Column
+
 import sqlalchemy as tsa
-from sqlalchemy.engine import url
+from sqlalchemy import create_engine
+from sqlalchemy import event
+from sqlalchemy import exc
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import pool
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import mock
+from sqlalchemy import util
+from sqlalchemy.engine import url
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import mock
+from sqlalchemy.testing import ne_
 from sqlalchemy.testing.engines import testing_engine
-from sqlalchemy.testing.mock import Mock, call, patch
-from sqlalchemy import event
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.mock import patch
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from sqlalchemy.testing.util import gc_collect
 
 
index 29e0900396be6a6e12f34ced988e1ca606beb368..41f75b8f8fb5e739a0eccf009c9072704f5eadee 100644 (file)
@@ -1,36 +1,35 @@
 import unicodedata
+
 import sqlalchemy as sa
-from sqlalchemy import schema, inspect, sql
-from sqlalchemy import (
-    MetaData,
-    Integer,
-    String,
-    Index,
-    ForeignKey,
-    UniqueConstraint,
-    FetchedValue,
-    DefaultClause,
-)
-from sqlalchemy.testing import (
-    ComparesTables,
-    engines,
-    AssertsCompiledSQL,
-    fixtures,
-    skip,
-)
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.testing import (
-    eq_,
-    eq_regex,
-    is_true,
-    assert_raises,
-    assert_raises_message,
-)
+from sqlalchemy import DefaultClause
+from sqlalchemy import FetchedValue
+from sqlalchemy import ForeignKey
+from sqlalchemy import Index
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import schema
+from sqlalchemy import sql
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.util import ue
+from sqlalchemy import UniqueConstraint
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import ComparesTables
 from sqlalchemy.testing import config
-from sqlalchemy.testing import mock
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import eq_regex
 from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_true
+from sqlalchemy.testing import mock
+from sqlalchemy.testing import skip
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.util import ue
+
 
 metadata, users = None, None
 
@@ -284,7 +283,10 @@ class ReflectionTest(fixtures.TestBase, ComparesTables):
             1,
         )
         if (
-            testing.requires.unique_constraint_reflection_no_index_overlap.enabled
+            # fmt: off
+            testing.requires.
+            unique_constraint_reflection_no_index_overlap.enabled
+            # fmt: on
         ):
             eq_(
                 len(
index ad2f29fa0346ac8842bd8fa30be943d62c2a53e5..1364683299c089cdec562771f096a8cc8450963e 100644 (file)
@@ -1,30 +1,27 @@
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    ne_,
-    expect_warnings,
-)
 import sys
+
+from sqlalchemy import create_engine
 from sqlalchemy import event
-from sqlalchemy.testing.engines import testing_engine
-from sqlalchemy import (
-    create_engine,
-    MetaData,
-    INT,
-    VARCHAR,
-    Sequence,
-    select,
-    Integer,
-    String,
-    func,
-    text,
-    exc,
-)
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
+from sqlalchemy import exc
+from sqlalchemy import func
+from sqlalchemy import INT
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
 from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import VARCHAR
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing.engines import testing_engine
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 users, metadata = None, None
index 9de7f5ab9ea6eb2ecaef32803d6066904f081bee..990262f2ca0b42273118536064a701f25ff81c95 100644 (file)
@@ -1,48 +1,47 @@
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    expect_warnings,
-    is_,
-)
-from sqlalchemy.testing import assertions
-from sqlalchemy.ext import declarative as decl
-from sqlalchemy.ext.hybrid import hybrid_property
-from sqlalchemy import exc
 import sqlalchemy as sa
-from sqlalchemy import testing, util
-from sqlalchemy import (
-    MetaData,
-    Integer,
-    String,
-    ForeignKey,
-    ForeignKeyConstraint,
-    Index,
-    UniqueConstraint,
-    CheckConstraint,
-)
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    relationship,
-    create_session,
-    class_mapper,
-    joinedload,
-    configure_mappers,
-    backref,
-    clear_mappers,
-    column_property,
-    composite,
-    Session,
-    properties,
-    deferred,
-)
-from sqlalchemy.util import with_metaclass
-from sqlalchemy.ext.declarative import declared_attr, synonym_for
-from sqlalchemy.testing import fixtures, mock
-from sqlalchemy.orm.events import MapperEvents
-from sqlalchemy.orm import mapper
+from sqlalchemy import CheckConstraint
 from sqlalchemy import event
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import Index
 from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy import UniqueConstraint
+from sqlalchemy import util
+from sqlalchemy.ext import declarative as decl
+from sqlalchemy.ext.declarative import declared_attr
+from sqlalchemy.ext.declarative import synonym_for
+from sqlalchemy.ext.hybrid import hybrid_property
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import composite
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import properties
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm.events import MapperEvents
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import assertions
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.util import with_metaclass
+
 
 Base = None
 
index c93fbc9dc9014a4f215662f8814c9ff12d5d370e..d61cc81c83cdedd421613c2caf12088626e501b3 100644 (file)
@@ -1,9 +1,13 @@
+import weakref
+
+from sqlalchemy import exc
+from sqlalchemy import MetaData
+from sqlalchemy.ext.declarative import clsregistry
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 from sqlalchemy.testing.util import gc_collect
-from sqlalchemy.testing import assert_raises_message, is_, eq_
-from sqlalchemy import exc, MetaData
-from sqlalchemy.ext.declarative import clsregistry
-import weakref
 
 
 class MockClass(object):
index 6cf0073b24833410195263b03d285d7f1992b3df..97c7dcd7c8aca0cea72478318053dee0c2cfde84 100644 (file)
@@ -1,37 +1,35 @@
-from sqlalchemy.testing import (
-    eq_,
-    le_,
-    assert_raises,
-    assert_raises_message,
-    is_,
-    is_true,
-    is_false,
-)
-from sqlalchemy.ext import declarative as decl
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    relationship,
-    create_session,
-    class_mapper,
-    configure_mappers,
-    clear_mappers,
-    polymorphic_union,
-    deferred,
-    Session,
-    mapper,
-)
-from sqlalchemy.ext.declarative import (
-    declared_attr,
-    AbstractConcreteBase,
-    ConcreteBase,
-    has_inherited_table,
-)
-from sqlalchemy.testing import fixtures, mock
+from sqlalchemy.ext import declarative as decl
+from sqlalchemy.ext.declarative import AbstractConcreteBase
+from sqlalchemy.ext.declarative import ConcreteBase
+from sqlalchemy.ext.declarative import declared_attr
+from sqlalchemy.ext.declarative import has_inherited_table
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import polymorphic_union
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_false
+from sqlalchemy.testing import is_true
+from sqlalchemy.testing import mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm.test_events import _RemoveListeners
 
+
 Base = None
 
 
@@ -1903,7 +1901,8 @@ class ConcreteExtensionConfigTest(
             "(SELECT cca.id AS id, cca.x AS x, cca.y AS y, "
             "cca.something_id AS something_id, 'ccb' AS type FROM cca) "
             "AS pjoin WHERE EXISTS (SELECT 1 FROM something "
-            "WHERE something.id = pjoin.something_id AND something.id = :id_1)",
+            "WHERE something.id = pjoin.something_id "
+            "AND something.id = :id_1)",
         )
 
         self.assert_compile(
@@ -1916,7 +1915,8 @@ class ConcreteExtensionConfigTest(
             "(SELECT cca.id AS id, cca.x AS x, cca.y AS y, "
             "cca.something_id AS something_id, 'ccb' AS type FROM cca) "
             "AS pjoin WHERE EXISTS (SELECT 1 FROM something "
-            "WHERE something.id = pjoin.something_id AND something.id = :id_1)",
+            "WHERE something.id = pjoin.something_id AND "
+            "something.id = :id_1)",
         )
 
     def test_abstract_in_hierarchy(self):
index f51a75b3e3593a7eb3529f3c44ca6b493e50327f..7fec772708aa7d10e6a02818d929e4a45f45e2e6 100644 (file)
@@ -1,32 +1,36 @@
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    is_,
-    expect_warnings,
-)
-from sqlalchemy.ext import declarative as decl
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey, select, func
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    relationship,
-    create_session,
-    class_mapper,
-    configure_mappers,
-    clear_mappers,
-    deferred,
-    column_property,
-    Session,
-    base as orm_base,
-    synonym,
-)
-from sqlalchemy.util import classproperty
-from sqlalchemy.ext.declarative import declared_attr, declarative_base
+from sqlalchemy.ext import declarative as decl
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.ext.declarative import declared_attr
+from sqlalchemy.orm import base as orm_base
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import deferred
 from sqlalchemy.orm import events as orm_events
-from sqlalchemy.testing import fixtures, mock
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import synonym
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from sqlalchemy.testing.util import gc_collect
+from sqlalchemy.util import classproperty
+
 
 Base = None
 
@@ -1319,7 +1323,6 @@ class DeclarativeMixinPropertyTest(
 
     def test_correct_for_proxies(self):
         from sqlalchemy.ext.hybrid import hybrid_property
-        from sqlalchemy.ext import hybrid
         from sqlalchemy import inspect
 
         class Mixin(object):
@@ -1388,7 +1391,8 @@ class DeclarativeMixinPropertyTest(
         s = Session()
         self.assert_compile(
             s.query(Base.data_syn).filter(Base.data_syn == "foo"),
-            "SELECT test.data AS test_data FROM test WHERE test.data = :data_1",
+            "SELECT test.data AS test_data FROM test "
+            "WHERE test.data = :data_1",
             dialect="default",
         )
         self.assert_compile(
@@ -1770,12 +1774,12 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL):
             @declared_attr.cascading
             def my_attr(cls):
                 if decl.has_inherited_table(cls):
-                    id = Column(ForeignKey("a.my_attr"), primary_key=True)
-                    asserted["b"].add(id)
+                    id_ = Column(ForeignKey("a.my_attr"), primary_key=True)
+                    asserted["b"].add(id_)
                 else:
-                    id = Column(Integer, primary_key=True)
-                    asserted["a"].add(id)
-                return id
+                    id_ = Column(Integer, primary_key=True)
+                    asserted["a"].add(id_)
+                return id_
 
         class A(Base, Mixin):
             __tablename__ = "a"
index e2bab0dd86cf1eb51a9182cef43763b6da7dec60..df1f0580c475ab6af74889909ab807a6189152d7 100644 (file)
@@ -1,12 +1,19 @@
-from sqlalchemy.testing import eq_, assert_raises
-from sqlalchemy.ext import declarative as decl
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import relationship, create_session, clear_mappers, Session
+from sqlalchemy.ext import declarative as decl
+from sqlalchemy.ext.declarative.base import _DeferredMapperConfig
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from sqlalchemy.testing.util import gc_collect
-from sqlalchemy.ext.declarative.base import _DeferredMapperConfig
 
 
 class DeclarativeReflectionBase(fixtures.TablesTest):
index 4e063a84b890703b2318c417dfce3c511dfd54b0..24b57cd6b34ca13af13eb01ef5cd179de25acb3c 100644 (file)
@@ -1,34 +1,42 @@
-from sqlalchemy.testing import eq_, assert_raises, is_
 import copy
 import pickle
 
-from sqlalchemy import Integer, ForeignKey, String, or_, MetaData
-from sqlalchemy.orm import (
-    relationship,
-    configure_mappers,
-    mapper,
-    Session,
-    collections,
-    sessionmaker,
-    aliased,
-    clear_mappers,
-    create_session,
-)
 from sqlalchemy import exc
-from sqlalchemy.orm.collections import collection, attribute_mapped_collection
-from sqlalchemy.ext.associationproxy import association_proxy
-from sqlalchemy.ext.associationproxy import _AssociationList
-from sqlalchemy.testing import assert_raises_message
-from sqlalchemy.testing.util import gc_collect
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import or_
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.testing.mock import Mock, call
-from sqlalchemy.testing.assertions import expect_warnings
+from sqlalchemy.engine import default
+from sqlalchemy.ext.associationproxy import _AssociationList
+from sqlalchemy.ext.associationproxy import association_proxy
 from sqlalchemy.ext.declarative import declarative_base
 from sqlalchemy.ext.declarative import declared_attr
-from sqlalchemy.engine import default
-from sqlalchemy import inspect
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import collections
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm.collections import attribute_mapped_collection
+from sqlalchemy.orm.collections import collection
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.assertions import expect_warnings
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import gc_collect
 
 
 class DictCollection(dict):
@@ -254,9 +262,9 @@ class _CollectionOperations(fixtures.TestBase):
         if obj not in self.session:
             self.session.add(obj)
         self.session.flush()
-        id, type_ = obj.id, type(obj)
+        id_, type_ = obj.id, type(obj)
         self.session.expunge_all()
-        return self.session.query(type_).get(id)
+        return self.session.query(type_).get(id_)
 
     def _test_sequence_ops(self):
         Parent, Child = self.Parent, self.Child
@@ -962,9 +970,9 @@ class ScalarTest(fixtures.TestBase):
             if obj not in session:
                 session.add(obj)
             session.flush()
-            id, type_ = obj.id, type(obj)
+            id_, type_ = obj.id, type(obj)
             session.expunge_all()
-            return session.query(type_).get(id)
+            return session.query(type_).get(id_)
 
         p = Parent("p")
 
@@ -1155,9 +1163,9 @@ class LazyLoadTest(fixtures.TestBase):
     def roundtrip(self, obj):
         self.session.add(obj)
         self.session.flush()
-        id, type_ = obj.id, type(obj)
+        id_, type_ = obj.id, type(obj)
         self.session.expunge_all()
-        return self.session.query(type_).get(id)
+        return self.session.query(type_).get(id_)
 
     def test_lazy_list(self):
         Parent, Child = self.Parent, self.Child
@@ -1526,7 +1534,16 @@ class ComparatorTest(fixtures.MappedTest, AssertsCompiledSQL):
 
     @classmethod
     def setup_mappers(cls):
-        users, Keyword, UserKeyword, singular, userkeywords, User, keywords, Singular = (
+        (
+            users,
+            Keyword,
+            UserKeyword,
+            singular,
+            userkeywords,
+            User,
+            keywords,
+            Singular,
+        ) = (
             cls.tables.users,
             cls.classes.Keyword,
             cls.classes.UserKeyword,
index e6bdd1d8cc88242c2d81083f5bf5eb8c0a2157f8..e2dd5b11e6d74dafcc5f168cf919edf54f7b08ab 100644 (file)
@@ -1,17 +1,24 @@
-from sqlalchemy.testing import fixtures
-from ..orm._fixtures import FixtureTest
-from sqlalchemy.ext.automap import automap_base
-from sqlalchemy.orm import relationship, interfaces, configure_mappers
-from sqlalchemy.ext.automap import generate_relationship
-from sqlalchemy.testing.mock import Mock, patch
-from sqlalchemy import String, Integer, ForeignKey, MetaData
-from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-
-from sqlalchemy import create_engine
+import random
 import threading
 import time
-import random
+
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy.ext.automap import automap_base
+from sqlalchemy.ext.automap import generate_relationship
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import interfaces
+from sqlalchemy.orm import relationship
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.mock import patch
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from ..orm._fixtures import FixtureTest
 
 
 class AutomapTest(fixtures.MappedTest):
index 8a6702dce92a11f9ac91d01980cd98d396b5b9e5..57c9447999f58f5f6b8d51a90486f3d5ce9e8f96 100644 (file)
@@ -1,27 +1,29 @@
-from sqlalchemy.orm import (
-    Session,
-    subqueryload,
-    mapper,
-    relationship,
-    lazyload,
-    backref,
-    aliased,
-    Load,
-    defaultload,
-)
-from sqlalchemy.testing import eq_, is_, is_not_
-from sqlalchemy.testing import assert_raises_message
+import contextlib
+import itertools
+
+from sqlalchemy import bindparam
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import func
 from sqlalchemy import testing
-from test.orm import _fixtures
 from sqlalchemy.ext import baked
-from sqlalchemy import bindparam, func
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import defaultload
 from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import lazyload
+from sqlalchemy.orm import Load
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import subqueryload
 from sqlalchemy.orm.query import Query
-import itertools
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
 from sqlalchemy.testing import mock
 from sqlalchemy.testing.assertsql import CompiledSQL
-import contextlib
-from sqlalchemy import exc as sa_exc
+from test.orm import _fixtures
 
 
 class BakedTest(_fixtures.FixtureTest):
index 22ab1f1634001e733ca72e629fe04292d004dc4e..ac6af0a96daa16fbb08a1ddb88ae44e1ba827d5a 100644 (file)
@@ -1,21 +1,28 @@
-from sqlalchemy import *
-from sqlalchemy.types import TypeEngine
-from sqlalchemy.sql.expression import (
-    ClauseElement,
-    ColumnClause,
-    FunctionElement,
-    Select,
-    BindParameter,
-    ColumnElement,
-)
-
-from sqlalchemy.schema import DDLElement, CreateColumn, CreateTable
-from sqlalchemy.ext.compiler import compiles, deregister
+from sqlalchemy import Column
+from sqlalchemy import column
+from sqlalchemy import desc
 from sqlalchemy import exc
-from sqlalchemy.testing import eq_
-from sqlalchemy.sql import table, column
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Numeric
+from sqlalchemy import select
+from sqlalchemy import Table
+from sqlalchemy import table
+from sqlalchemy.ext.compiler import compiles
+from sqlalchemy.ext.compiler import deregister
+from sqlalchemy.schema import CreateColumn
+from sqlalchemy.schema import CreateTable
+from sqlalchemy.schema import DDLElement
+from sqlalchemy.sql.expression import BindParameter
+from sqlalchemy.sql.expression import ClauseElement
+from sqlalchemy.sql.expression import ColumnClause
+from sqlalchemy.sql.expression import FunctionElement
+from sqlalchemy.sql.expression import Select
 from sqlalchemy.testing import assert_raises_message
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.types import TypeEngine
 
 
 class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL):
@@ -64,11 +71,11 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL):
             pass
 
         @compiles(MyType, "sqlite")
-        def visit_type(type, compiler, **kw):
+        def visit_sqlite_type(type_, compiler, **kw):
             return "SQLITE_FOO"
 
         @compiles(MyType, "postgresql")
-        def visit_type(type, compiler, **kw):
+        def visit_pg_type(type_, compiler, **kw):
             return "POSTGRES_FOO"
 
         from sqlalchemy.dialects.sqlite import base as sqlite
@@ -190,7 +197,7 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL):
         try:
 
             @compiles(Select)
-            def compile(element, compiler, **kw):
+            def compile_(element, compiler, **kw):
                 return "OVERRIDE"
 
             s1 = select([t1])
@@ -209,7 +216,7 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL):
             __visit_name__ = "drop_thingy"
 
         @compiles(AddThingy, "sqlite")
-        def visit_add_thingy(thingy, compiler, **kw):
+        def visit_add_thingy_sqlite(thingy, compiler, **kw):
             return "ADD SPECIAL SL THINGY"
 
         @compiles(AddThingy)
@@ -235,7 +242,7 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL):
         )
 
         @compiles(DropThingy, "sqlite")
-        def visit_drop_thingy(thingy, compiler, **kw):
+        def visit_drop_thingy_sqlite(thingy, compiler, **kw):
             return "DROP SPECIAL SL THINGY"
 
         self.assert_compile(
@@ -255,7 +262,7 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL):
             return "utcnow()"
 
         @compiles(MyUtcFunction, "postgresql")
-        def visit_myfunc(element, compiler, **kw):
+        def visit_myfunc_pg(element, compiler, **kw):
             return "timezone('utc', current_timestamp)"
 
         self.assert_compile(
@@ -315,7 +322,7 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL):
             return element.name
 
         @compiles(Sub1)
-        def visit_base(element, compiler, **kw):
+        def visit_sub1(element, compiler, **kw):
             return "FOO" + element.name
 
         self.assert_compile(
@@ -348,7 +355,7 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL):
         )
 
         @compiles(Sub1)
-        def visit_base(element, compiler, **kw):
+        def visit_sub1(element, compiler, **kw):
             return "FOO" + element.name
 
         self.assert_compile(
@@ -371,7 +378,7 @@ class DefaultOnExistingTest(fixtures.TestBase, AssertsCompiledSQL):
         t1 = table("t1", column("c1"), column("c2"))
 
         @compiles(Select, "sqlite")
-        def compile(element, compiler, **kw):
+        def compile_(element, compiler, **kw):
             return "OVERRIDE"
 
         s1 = select([t1])
index 277178af995316e169eede2aca98236d85223d8b..161c187625a97fb67084ddcfaeb029655773090c 100644 (file)
@@ -1,21 +1,23 @@
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message, ne_
-from sqlalchemy import util
 import sqlalchemy as sa
-from sqlalchemy.orm import class_mapper
+from sqlalchemy import event
+from sqlalchemy import util
+from sqlalchemy.ext import instrumentation
 from sqlalchemy.orm import attributes
-from sqlalchemy.orm.attributes import (
-    set_attribute,
-    get_attribute,
-    del_attribute,
-)
-from sqlalchemy.orm.instrumentation import is_instrumented
+from sqlalchemy.orm import class_mapper
 from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import events
+from sqlalchemy.orm.attributes import del_attribute
+from sqlalchemy.orm.attributes import get_attribute
+from sqlalchemy.orm.attributes import set_attribute
+from sqlalchemy.orm.instrumentation import is_instrumented
+from sqlalchemy.orm.instrumentation import manager_of_class
+from sqlalchemy.orm.instrumentation import register_class
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy.ext import instrumentation
-from sqlalchemy.orm.instrumentation import register_class, manager_of_class
+from sqlalchemy.testing import ne_
 from sqlalchemy.testing.util import decorator
-from sqlalchemy.orm import events
-from sqlalchemy import event
 
 
 @decorator
@@ -236,14 +238,12 @@ class UserDefinedExtensionTest(_ExtBase, fixtures.ORMTest):
             )
 
             if base is object:
-                assert (
-                    Foo
-                    not in instrumentation._instrumentation_factory._state_finders
+                assert Foo not in (
+                    instrumentation._instrumentation_factory._state_finders
                 )
             else:
-                assert (
-                    Foo
-                    in instrumentation._instrumentation_factory._state_finders
+                assert Foo in (
+                    instrumentation._instrumentation_factory._state_finders
                 )
 
             f = Foo()
index def82faf7ebc4371044258a50934013ff410c271..8d590c49642e5c734d47b5ccff334af18a6ab511 100644 (file)
@@ -1,15 +1,34 @@
 import datetime
 import os
-from sqlalchemy import *
+
+from sqlalchemy import Column
+from sqlalchemy import DateTime
 from sqlalchemy import event
-from sqlalchemy import sql, util
-from sqlalchemy.orm import *
+from sqlalchemy import Float
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import sql
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import util
 from sqlalchemy.ext.horizontal_shard import ShardedSession
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import selectinload
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
 from sqlalchemy.sql import operators
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import provision
 from sqlalchemy.testing.engines import testing_engine
-from sqlalchemy.testing import eq_
-from sqlalchemy import testing
+
 
 # TODO: ShardTest can be turned into a base for further subclasses
 
@@ -388,9 +407,6 @@ class ShardTest(object):
             assert inspect(t).deleted is (t.temperature >= 80)
 
 
-from sqlalchemy.testing import provision
-
-
 class DistinctEngineShardTest(ShardTest, fixtures.TestBase):
     def _init_dbs(self):
         db1 = testing_engine(
index 55fd2b1a548217758785c17422aa2c5cf11cce55..ab57ce6f47ea6e7eb51702ec55dd385360d8cb9b 100644 (file)
@@ -1,17 +1,23 @@
-from sqlalchemy import func, Integer, Numeric, String, ForeignKey
-from sqlalchemy.orm import relationship, Session, aliased, persistence
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.ext.declarative import declarative_base
+from decimal import Decimal
+
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import Numeric
+from sqlalchemy import String
 from sqlalchemy.ext import hybrid
-from sqlalchemy.testing import (
-    eq_,
-    is_,
-    AssertsCompiledSQL,
-    assert_raises_message,
-)
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import persistence
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy import inspect
-from decimal import Decimal
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.schema import Column
 
 
 class PropertyComparatorTest(fixtures.TestBase, AssertsCompiledSQL):
index 28ae6ab6bf963a8276160827de3d51bb8c1a197d..ed7da3ad0bb55f8516ec169f8ab18e492d90ae37 100644 (file)
@@ -1,15 +1,21 @@
-from sqlalchemy.testing import assert_raises
 import sqlalchemy as sa
+from sqlalchemy import inspect
+from sqlalchemy import Integer
 from sqlalchemy import testing
-from sqlalchemy import Integer, Text
-from sqlalchemy.sql.sqltypes import ARRAY, JSON
-from sqlalchemy.testing.schema import Column
+from sqlalchemy import Text
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.ext.indexable import index_property
 from sqlalchemy.orm import Session
+from sqlalchemy.sql.sqltypes import ARRAY
+from sqlalchemy.sql.sqltypes import JSON
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy.ext.indexable import index_property
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.testing import eq_, ne_, is_, in_, not_in_
-from sqlalchemy import inspect
+from sqlalchemy.testing import in_
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing import not_in_
+from sqlalchemy.testing.schema import Column
 
 
 class IndexPropertyTest(fixtures.TestBase):
index d46ace9a8adcdaae21712a4c930820c908c49a9f..9b8f761e9c0feabc002835f1674390db8c6e3ab9 100644 (file)
@@ -1,17 +1,30 @@
-from sqlalchemy import Integer, ForeignKey, String, func
-from sqlalchemy.types import PickleType, TypeDecorator, VARCHAR
-from sqlalchemy.orm import mapper, Session, composite, column_property
-from sqlalchemy.orm.mapper import Mapper
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.ext.mutable import MutableComposite
+from sqlalchemy.ext.mutable import MutableDict
+from sqlalchemy.ext.mutable import MutableList
+from sqlalchemy.ext.mutable import MutableSet
 from sqlalchemy.orm import attributes
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import composite
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Session
 from sqlalchemy.orm.instrumentation import ClassManager
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.testing import eq_, assert_raises_message, assert_raises
-from sqlalchemy.testing.util import picklers
+from sqlalchemy.orm.mapper import Mapper
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy.ext.mutable import MutableComposite
-from sqlalchemy.ext.mutable import MutableDict, MutableList, MutableSet
 from sqlalchemy.testing import mock
-from sqlalchemy import event
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import picklers
+from sqlalchemy.types import PickleType
+from sqlalchemy.types import TypeDecorator
+from sqlalchemy.types import VARCHAR
 
 
 class Foo(fixtures.BasicEntity):
index c417c7153dc796bc0805035279cd07c72af8088a..a1a6c69188d59550b5412a901499689d769f73f0 100644 (file)
@@ -1,10 +1,16 @@
-from sqlalchemy import Integer, ForeignKey, String, MetaData
-from sqlalchemy.orm import relationship, mapper, create_session
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
+from sqlalchemy import testing
 from sqlalchemy.ext.orderinglist import ordering_list
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from sqlalchemy.testing.util import picklers
 
 
@@ -165,11 +171,11 @@ class OrderingListTest(fixtures.TestBase):
         session.add(s1)
         session.flush()
 
-        id = s1.id
+        id_ = s1.id
         session.expunge_all()
         del s1
 
-        srt = session.query(Slide).get(id)
+        srt = session.query(Slide).get(id_)
 
         self.assert_(srt.bullets)
         self.assert_(len(srt.bullets) == 4)
@@ -230,11 +236,11 @@ class OrderingListTest(fixtures.TestBase):
         session.add(s1)
         session.flush()
 
-        id = s1.id
+        id_ = s1.id
         session.expunge_all()
         del s1
 
-        srt = session.query(Slide).get(id)
+        srt = session.query(Slide).get(id_)
 
         self.assert_(srt.bullets)
         self.assert_(len(srt.bullets) == 5)
@@ -248,7 +254,7 @@ class OrderingListTest(fixtures.TestBase):
         session.flush()
         session.expunge_all()
 
-        srt = session.query(Slide).get(id)
+        srt = session.query(Slide).get(id_)
         titles = ["s1/b1", "s1/b2", "s1/b100", "s1/b4", "raw", "raw2"]
         found = [b.text for b in srt.bullets]
         eq_(titles, found)
@@ -287,11 +293,11 @@ class OrderingListTest(fixtures.TestBase):
         session.add(s1)
         session.flush()
 
-        id = s1.id
+        id_ = s1.id
         session.expunge_all()
         del s1
 
-        srt = session.query(Slide).get(id)
+        srt = session.query(Slide).get(id_)
 
         self.assert_(srt.bullets)
         self.assert_(len(srt.bullets) == 6)
@@ -336,11 +342,11 @@ class OrderingListTest(fixtures.TestBase):
         session.add(s1)
         session.flush()
 
-        id = s1.id
+        id_ = s1.id
         session.expunge_all()
         del s1
 
-        srt = session.query(Slide).get(id)
+        srt = session.query(Slide).get(id_)
 
         self.assert_(srt.bullets)
         self.assert_(len(srt.bullets) == 3)
@@ -373,12 +379,12 @@ class OrderingListTest(fixtures.TestBase):
         self.assert_(new_bullet.position == 1)
         self.assert_(len(s1.bullets) == 3)
 
-        id = s1.id
+        id_ = s1.id
 
         session.flush()
         session.expunge_all()
 
-        srt = session.query(Slide).get(id)
+        srt = session.query(Slide).get(id_)
 
         self.assert_(srt.bullets)
         self.assert_(len(srt.bullets) == 3)
index 3173c0234ebe38e5ef2b4ac118ea88b6ae54dc40..e5490146c7ddcb23c6c6a2fa6b2a651638768d4c 100644 (file)
@@ -1,34 +1,30 @@
 # coding: utf-8
 
-from sqlalchemy.ext import serializer
+from sqlalchemy import desc
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import join
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import (
-    Integer,
-    String,
-    ForeignKey,
-    select,
-    desc,
-    func,
-    util,
-    MetaData,
-    literal_column,
-    join,
-)
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import (
-    relationship,
-    sessionmaker,
-    scoped_session,
-    class_mapper,
-    mapper,
-    joinedload,
-    configure_mappers,
-    aliased,
-)
-from sqlalchemy.testing import eq_, AssertsCompiledSQL
-from sqlalchemy.util import u, ue
+from sqlalchemy.ext import serializer
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import scoped_session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.util import ue
 
 
 def pickle_protocols():
index 57a042447a32ef5a078e644c73dd51750be89e82..bb51777a31e3835e9fca5bb5667a858e2fdd7974 100644 (file)
@@ -1,15 +1,15 @@
-from sqlalchemy import MetaData, Integer, String, ForeignKey
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import util
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import (
-    attributes,
-    mapper,
-    relationship,
-    backref,
-    configure_mappers,
-)
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+
 
 __all__ = ()
 
@@ -56,7 +56,26 @@ class FixtureTest(fixtures.MappedTest):
 
     @classmethod
     def _setup_stock_mapping(cls):
-        Node, composite_pk_table, users, Keyword, items, Dingaling, order_items, item_keywords, Item, User, dingalings, Address, keywords, CompositePk, nodes, Order, orders, addresses = (
+        (
+            Node,
+            composite_pk_table,
+            users,
+            Keyword,
+            items,
+            Dingaling,
+            order_items,
+            item_keywords,
+            Item,
+            User,
+            dingalings,
+            Address,
+            keywords,
+            CompositePk,
+            nodes,
+            Order,
+            orders,
+            addresses,
+        ) = (
             cls.classes.Node,
             cls.tables.composite_pk_table,
             cls.tables.users,
index 668ea6160264c3b8232b14b1f41e6fcac319da53..cc253a3806dcd17eeb1646530feed3353de2533d 100644 (file)
@@ -1,14 +1,15 @@
-from sqlalchemy import Integer, String, ForeignKey
-from sqlalchemy.orm import (
-    relationship,
-    mapper,
-    create_session,
-    polymorphic_union,
-)
-
-from sqlalchemy.testing import AssertsCompiledSQL, fixtures
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import polymorphic_union
+from sqlalchemy.orm import relationship
+from sqlalchemy.testing import AssertsCompiledSQL
 from sqlalchemy.testing import config
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class Company(fixtures.ComparableEntity):
index 55ae264968367295b197d03a6d6f142920d32d2f..9a06bfa06b2f3e126dbe8d06a21f68e8d230a8ba 100644 (file)
@@ -1,10 +1,16 @@
-from sqlalchemy import *
-from sqlalchemy.orm import *
-from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE
-
-from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import polymorphic_union
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm.interfaces import MANYTOONE
+from sqlalchemy.orm.interfaces import ONETOMANY
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 def produce_test(parent, child, direction):
index 98166c21b559016ba141c67d1469477f0cd9f2cd..f430e761f8e345d2d5b4fedb26df0d723e060a46 100644 (file)
@@ -1,12 +1,13 @@
-from sqlalchemy import *
-from sqlalchemy import util
-from sqlalchemy.orm import *
-
-from sqlalchemy.testing.util import function_named
-from sqlalchemy.testing import fixtures
-from test.orm import _fixtures
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
 from sqlalchemy.testing import eq_
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import function_named
 
 
 class ABCTest(fixtures.MappedTest):
index 43c667abd70033795afacdf412800ee21bac388e..ee869ab22370588d1684fc2d0942f0284b9fb5cc 100644 (file)
@@ -3,18 +3,35 @@ These are generally tests derived from specific user issues.
 
 """
 
-from sqlalchemy.testing import eq_
-from sqlalchemy import *
+from sqlalchemy import exists
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy import Unicode
 from sqlalchemy import util
-from sqlalchemy.orm import *
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import join
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import polymorphic_union
+from sqlalchemy.orm import Query
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 from sqlalchemy.orm.interfaces import MANYTOONE
 from sqlalchemy.testing import AssertsExecutionResults
-from sqlalchemy import testing
-from sqlalchemy.testing.util import function_named
-from sqlalchemy.testing import fixtures
-from test.orm import _fixtures
 from sqlalchemy.testing import eq_
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import function_named
 
 
 class AttrSettable(object):
@@ -485,8 +502,8 @@ def _generate_test(jointype="join1", usedata=False):
 
 for jointype in ["join1", "join2", "join3", "join4"]:
     for data in (True, False):
-        func = _generate_test(jointype, data)
-        setattr(RelationshipTest3, func.__name__, func)
+        _fn = _generate_test(jointype, data)
+        setattr(RelationshipTest3, _fn.__name__, _fn)
 del func
 
 
@@ -1481,7 +1498,8 @@ class MultiLevelTest(fixtures.MappedTest):
 class ManyToManyPolyTest(fixtures.MappedTest):
     @classmethod
     def define_tables(cls, metadata):
-        global base_item_table, item_table, base_item_collection_table, collection_table
+        global base_item_table, item_table
+        global base_item_collection_table, collection_table
         base_item_table = Table(
             "base_item",
             metadata,
index d871a6a98c2307548f0f279dbca457876aaf6330..f2336980c8313d040cc89dface6b037a9ef66c0e 100644 (file)
@@ -1,20 +1,48 @@
-import warnings
-from sqlalchemy.testing import eq_, is_, assert_raises, assert_raises_message
-from sqlalchemy import *
-from sqlalchemy import exc as sa_exc, util, event
-from sqlalchemy.orm import *
-from sqlalchemy.orm.util import instance_str
-from sqlalchemy.orm import exc as orm_exc, attributes
-from sqlalchemy.testing.assertsql import AllOf, CompiledSQL, RegexSQL, Or
-from sqlalchemy.sql import table, column
+from sqlalchemy import Boolean
+from sqlalchemy import case
+from sqlalchemy import column
+from sqlalchemy import event
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import table
 from sqlalchemy import testing
+from sqlalchemy import util
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import composite
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import object_mapper
+from sqlalchemy.orm import polymorphic_union
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import synonym
+from sqlalchemy.orm.util import instance_str
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from test.orm import _fixtures
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy import inspect
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.testing.util import gc_collect
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.assertsql import AllOf
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.assertsql import Or
+from sqlalchemy.testing.assertsql import RegexSQL
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class O2MTest(fixtures.MappedTest):
@@ -1015,7 +1043,8 @@ class M2OUseGetTest(fixtures.MappedTest):
                 # the 'primaryjoin' looks just like "Sub"'s "get" clause
                 # (based on the Base id), and foreign_keys since that join
                 # condition doesn't actually have any fks in it
-                # 'sub':relationship(Sub, primaryjoin=base.c.id==related.c.sub_id,
+                # 'sub':relationship(Sub,
+                # primaryjoin=base.c.id==related.c.sub_id,
                 # foreign_keys=related.c.sub_id)
                 # now we can use this:
                 "sub": relationship(Sub)
@@ -1984,7 +2013,7 @@ class DistinctPKTest(fixtures.MappedTest):
             r"On mapper Mapper\|Employee\|employees, "
             "primary key column 'persons.id' is being "
             "combined with distinct primary key column 'employees.eid' "
-            "in attribute 'id'.  Use explicit properties to give "
+            "in attribute 'id'. Use explicit properties to give "
             "each column its own mapped attribute name.",
             self._do_test,
             True,
index 3c1b4b08ebd09a69164b40d34f84770af993583f..acbf49a2036cee75ae160046350a7740aea53889 100644 (file)
@@ -1,16 +1,25 @@
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message
-from sqlalchemy import *
-from sqlalchemy.orm import *
-from sqlalchemy.orm import exc as orm_exc
-from sqlalchemy.testing import *
-import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import fixtures
+from sqlalchemy.ext.hybrid import hybrid_property
 from sqlalchemy.orm import attributes
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import polymorphic_union
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import eq_
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.ext.hybrid import hybrid_property
+from sqlalchemy.testing import fixtures
 from sqlalchemy.testing import mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class Employee(object):
@@ -72,7 +81,8 @@ class Company(object):
 class ConcreteTest(fixtures.MappedTest):
     @classmethod
     def define_tables(cls, metadata):
-        global managers_table, engineers_table, hackers_table, companies, employees_table
+        global managers_table, engineers_table, hackers_table
+        global companies, employees_table
         companies = Table(
             "companies",
             metadata,
index c7196a365c20cabc6dc14172655d19e37d13a2fc..dc162321fb919d454958119ff100cd4617e514ee 100644 (file)
@@ -1,8 +1,14 @@
+from sqlalchemy import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import eq_
-from sqlalchemy import *
-from sqlalchemy.orm import *
-
-from sqlalchemy import testing
 from sqlalchemy.testing import fixtures
 
 
index 55e48f25084494d5bb06327fa5e81d87911606d9..5c3b639c4126b393ccb50b053c8a41eeb3579248 100644 (file)
@@ -1,9 +1,15 @@
-from sqlalchemy import *
-from sqlalchemy.orm import *
-
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import fixtures
-from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class PolymorphicCircularTest(fixtures.MappedTest):
index 8f4abae41aa41af2bff21d62af7c37c96ad6ecab..8f1dc01888b94d42790c56f70a0e35cbd4f1f55b 100644 (file)
@@ -1,25 +1,27 @@
-from sqlalchemy import String, Integer, Column, ForeignKey
-from sqlalchemy.orm import (
-    relationship,
-    Session,
-    joinedload,
-    selectin_polymorphic,
-    selectinload,
-    with_polymorphic,
-    backref,
-)
-from sqlalchemy.testing import fixtures
+from sqlalchemy import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import selectin_polymorphic
+from sqlalchemy.orm import selectinload
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import with_polymorphic
 from sqlalchemy.testing import eq_
-from sqlalchemy.testing.assertsql import AllOf, CompiledSQL, EachOf, Or
-from ._poly_fixtures import (
-    Company,
-    Person,
-    Engineer,
-    Manager,
-    _Polymorphic,
-    GeometryFixtureBase,
-)
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertsql import AllOf
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.assertsql import EachOf
+from sqlalchemy.testing.assertsql import Or
+from ._poly_fixtures import _Polymorphic
+from ._poly_fixtures import Company
+from ._poly_fixtures import Engineer
+from ._poly_fixtures import GeometryFixtureBase
+from ._poly_fixtures import Manager
+from ._poly_fixtures import Person
 
 
 class BaseAndSubFixture(object):
@@ -102,9 +104,11 @@ class BaseAndSubFixture(object):
             AllOf(
                 EachOf(
                     CompiledSQL(
-                        "SELECT asub.id AS asub_id, a.id AS a_id, a.type AS a_type, "
+                        "SELECT asub.id AS asub_id, a.id AS a_id, "
+                        "a.type AS a_type, "
                         "asub.asubdata AS asub_asubdata FROM a JOIN asub "
-                        "ON a.id = asub.id WHERE a.id IN ([EXPANDING_primary_keys]) "
+                        "ON a.id = asub.id "
+                        "WHERE a.id IN ([EXPANDING_primary_keys]) "
                         "ORDER BY a.id",
                         {"primary_keys": [2]},
                     ),
index 67ae78fb45d7598c0dadea738f7d45f246702b7b..635f91b87be4dc24c95290e0d2f1ac84d3919c64 100644 (file)
@@ -1,15 +1,23 @@
 """tests basic polymorphic mapper loading/saving, minimal relationships"""
 
-from sqlalchemy.testing import eq_, is_, assert_raises, assert_raises_message
-from sqlalchemy import *
-from sqlalchemy.orm import *
-from sqlalchemy.orm import exc as orm_exc
 from sqlalchemy import exc as sa_exc
-from sqlalchemy.testing.schema import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.testing.util import function_named
-from test.orm import _fixtures
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import polymorphic_union
+from sqlalchemy.orm import relationship
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.util import function_named
 
 
 class Person(fixtures.ComparableEntity):
@@ -505,19 +513,19 @@ def _generate_round_trip_test(
 
 for lazy_relationship in [True, False]:
     for redefine_colprop in [True, False]:
-        for with_polymorphic in ["unions", "joins", "auto", "none"]:
-            if with_polymorphic == "unions":
+        for with_polymorphic_ in ["unions", "joins", "auto", "none"]:
+            if with_polymorphic_ == "unions":
                 for include_base in [True, False]:
                     _generate_round_trip_test(
                         include_base,
                         lazy_relationship,
                         redefine_colprop,
-                        with_polymorphic,
+                        with_polymorphic_,
                     )
             else:
                 _generate_round_trip_test(
                     False,
                     lazy_relationship,
                     redefine_colprop,
-                    with_polymorphic,
+                    with_polymorphic_,
                 )
index a0279f9e7169a51e067898ad758c3cb8cf111634..508de986c13726cacd3b25758bcbccd4ba1da3f5 100644 (file)
@@ -1,34 +1,29 @@
-from sqlalchemy import func, desc, select
-from sqlalchemy.orm import (
-    interfaces,
-    create_session,
-    joinedload,
-    joinedload_all,
-    subqueryload,
-    subqueryload_all,
-    aliased,
-    class_mapper,
-    with_polymorphic,
-)
+from sqlalchemy import desc
 from sqlalchemy import exc as sa_exc
-
+from sqlalchemy import func
+from sqlalchemy import select
 from sqlalchemy import testing
-from sqlalchemy.testing import assert_raises, eq_
-
-from ._poly_fixtures import (
-    Company,
-    Person,
-    Engineer,
-    Manager,
-    Boss,
-    Machine,
-    Paperwork,
-    _Polymorphic,
-    _PolymorphicPolymorphic,
-    _PolymorphicUnions,
-    _PolymorphicJoins,
-    _PolymorphicAliasedJoins,
-)
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import subqueryload_all
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import eq_
+from ._poly_fixtures import _Polymorphic
+from ._poly_fixtures import _PolymorphicAliasedJoins
+from ._poly_fixtures import _PolymorphicJoins
+from ._poly_fixtures import _PolymorphicPolymorphic
+from ._poly_fixtures import _PolymorphicUnions
+from ._poly_fixtures import Boss
+from ._poly_fixtures import Company
+from ._poly_fixtures import Engineer
+from ._poly_fixtures import Machine
+from ._poly_fixtures import Manager
+from ._poly_fixtures import Paperwork
+from ._poly_fixtures import Person
 
 
 class _PolymorphicTestBase(object):
index 24ed47f702c7d62b6a1efffe3f9d424d476c55bf..4174d01e857a0b01e06f108784e27ba87c042376 100644 (file)
@@ -1,10 +1,19 @@
 from datetime import datetime
-from sqlalchemy import *
-from sqlalchemy.orm import *
 
-from sqlalchemy import testing
+from sqlalchemy import DateTime
+from sqlalchemy import Float
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import LargeBinary
+from sqlalchemy import String
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import fixtures
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class InheritTest(fixtures.MappedTest):
index a16d9dc346b555fc792c3a22c3a3f98d2930630c..887453b1bfdc6ad3ac87c7f80380a3c8ad21315c 100644 (file)
@@ -1,25 +1,27 @@
-from sqlalchemy.orm import (
-    create_session,
-    relationship,
-    mapper,
-    contains_eager,
-    joinedload,
-    subqueryload,
-    subqueryload_all,
-    Session,
-    aliased,
-    with_polymorphic,
-    joinedload_all,
-    backref,
-)
-
-from sqlalchemy import Integer, String, ForeignKey, select, func
-from sqlalchemy.engine import default
-
-from sqlalchemy.testing import AssertsCompiledSQL, fixtures
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.testing import assert_raises, eq_, is_
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import contains_eager
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import subqueryload_all
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class Company(fixtures.ComparableEntity):
index cd7e3be40ba0bbf314c79a687d3099731ec4b71d..335b55e2b1449e372d5fa665f68b74ecc327bd0a 100644 (file)
@@ -1,10 +1,14 @@
-from sqlalchemy import String, Integer, ForeignKey, select
-from sqlalchemy.orm import mapper, Session
-
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-
-from sqlalchemy.testing import fixtures, eq_
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class InheritingSelectablesTest(fixtures.MappedTest):
index 13e1937a4d3dcee69c308279119b146567a215bc..aae9312d41190cca7c64f03090a1e231890b1806 100644 (file)
@@ -1,12 +1,26 @@
-from sqlalchemy.testing import eq_
-from sqlalchemy import *
-from sqlalchemy.orm import *
-
-from sqlalchemy import testing
-from test.orm import _fixtures
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
 from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import literal_column
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import Bundle
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class SingleInheritanceTest(testing.AssertsCompiledSQL, fixtures.MappedTest):
@@ -615,7 +629,15 @@ class RelationshipToSingleTest(
             pass
 
     def test_of_type(self):
-        JuniorEngineer, Company, companies, Manager, Employee, employees, Engineer = (
+        (
+            JuniorEngineer,
+            Company,
+            companies,
+            Manager,
+            Employee,
+            employees,
+            Engineer,
+        ) = (
             self.classes.JuniorEngineer,
             self.classes.Company,
             self.tables.companies,
@@ -1026,7 +1048,15 @@ class RelationshipToSingleTest(
             )
 
     def test_relationship_to_subclass(self):
-        JuniorEngineer, Company, companies, Manager, Employee, employees, Engineer = (
+        (
+            JuniorEngineer,
+            Company,
+            companies,
+            Manager,
+            Employee,
+            employees,
+            Engineer,
+        ) = (
             self.classes.JuniorEngineer,
             self.classes.Company,
             self.tables.companies,
index 014eb15345edc94fb009dd59b89848d7975ff515..3ff6c191c4aa4e4396b4936b158db448ccdd8df6 100644 (file)
@@ -1,42 +1,19 @@
-from sqlalchemy import Integer, String, ForeignKey, func, desc, and_, or_
-from sqlalchemy.orm import (
-    interfaces,
-    relationship,
-    mapper,
-    clear_mappers,
-    create_session,
-    joinedload,
-    joinedload_all,
-    subqueryload,
-    subqueryload_all,
-    polymorphic_union,
-    aliased,
-    class_mapper,
-    with_polymorphic,
-)
-from sqlalchemy import exc as sa_exc
-from sqlalchemy.engine import default
-
-from sqlalchemy.testing import AssertsCompiledSQL, fixtures
+from sqlalchemy import and_
+from sqlalchemy import or_
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.testing import assert_raises, eq_
-
-from ._poly_fixtures import (
-    Company,
-    Person,
-    Engineer,
-    Manager,
-    Boss,
-    Machine,
-    Paperwork,
-    _PolymorphicFixtureBase,
-    _Polymorphic,
-    _PolymorphicPolymorphic,
-    _PolymorphicUnions,
-    _PolymorphicJoins,
-    _PolymorphicAliasedJoins,
-)
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.testing import eq_
+from ._poly_fixtures import _Polymorphic
+from ._poly_fixtures import _PolymorphicAliasedJoins
+from ._poly_fixtures import _PolymorphicFixtureBase
+from ._poly_fixtures import _PolymorphicJoins
+from ._poly_fixtures import _PolymorphicPolymorphic
+from ._poly_fixtures import _PolymorphicUnions
+from ._poly_fixtures import Boss
+from ._poly_fixtures import Engineer
+from ._poly_fixtures import Manager
+from ._poly_fixtures import Person
 
 
 class _WithPolymorphicBase(_PolymorphicFixtureBase):
index 823f000253c6d533449470863a39af3bde1a9f41..669b1dc4846c36738db6ace7ba10d07d5c016907 100644 (file)
@@ -1,9 +1,15 @@
-from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey, func, select
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import mapper, relationship, create_session
-from sqlalchemy.testing import fixtures
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class AssociationTest(fixtures.MappedTest):
index 711dd2a991ae74eefa5cb9628e906eda0572ba9a..0c2dcdf3daca27a64e3f76041c808de8d21e81f5 100644 (file)
@@ -9,12 +9,19 @@ be cleaned up and modernized.
 import datetime
 
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey, table, text
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import mapper, relationship, backref, create_session
+from sqlalchemy import text
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class EagerTest(fixtures.MappedTest):
@@ -268,8 +275,8 @@ class EagerTest(fixtures.MappedTest):
             sa.and_(
                 tests.c.owner_id == 1,
                 sa.or_(
-                    options.c.someoption == None,  # noqa
-                    options.c.someoption == False,
+                    options.c.someoption == None,
+                    options.c.someoption == False,  # noqa
                 ),
             )
         )
@@ -292,8 +299,8 @@ class EagerTest(fixtures.MappedTest):
             sa.and_(
                 tests.c.owner_id == 1,
                 sa.or_(
-                    options.c.someoption == None,  # noqa
-                    options.c.someoption == False,
+                    options.c.someoption == None,
+                    options.c.someoption == False,  # noqa
                 ),
             )
         ).outerjoin("owner_option")
@@ -706,7 +713,16 @@ class EagerTest5(fixtures.MappedTest):
                 self.comment = comment
 
     def test_basic(self):
-        Comment, Derived, derived, comments, DerivedII, Base, base, derivedII = (
+        (
+            Comment,
+            Derived,
+            derived,
+            comments,
+            DerivedII,
+            Base,
+            base,
+            derivedII,
+        ) = (
             self.classes.Comment,
             self.classes.Derived,
             self.tables.derived,
@@ -836,7 +852,16 @@ class EagerTest6(fixtures.MappedTest):
             pass
 
     def test_one(self):
-        Part, inherited_part, design_types, DesignType, parts, design, Design, InheritedPart = (
+        (
+            Part,
+            inherited_part,
+            design_types,
+            DesignType,
+            parts,
+            design,
+            Design,
+            InheritedPart,
+        ) = (
             self.classes.Part,
             self.tables.inherited_part,
             self.tables.design_types,
index 9dd3889893a4c94b000c6b9abeb2f3f42233d984..2690c7442b2eb7e080d2b5b0ab6ed39032f14918 100644 (file)
@@ -1,24 +1,26 @@
 import pickle
-from sqlalchemy.orm import attributes, instrumentation, exc as orm_exc
-from sqlalchemy.orm.collections import collection
-from sqlalchemy.orm.interfaces import AttributeExtension
-from sqlalchemy import exc as sa_exc
-from sqlalchemy.testing import (
-    eq_,
-    ne_,
-    assert_raises,
-    assert_raises_message,
-    is_true,
-    is_false,
-    is_,
-)
-from sqlalchemy.testing import fixtures
-from sqlalchemy.testing.util import gc_collect, all_partial_orderings
-from sqlalchemy.util import jython
+
 from sqlalchemy import event
+from sqlalchemy import exc as sa_exc
 from sqlalchemy import testing
-from sqlalchemy.testing.mock import Mock, call
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import instrumentation
+from sqlalchemy.orm.collections import collection
+from sqlalchemy.orm.interfaces import AttributeExtension
 from sqlalchemy.orm.state import InstanceState
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_false
+from sqlalchemy.testing import is_true
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.util import all_partial_orderings
+from sqlalchemy.testing.util import gc_collect
+
 
 # global for pickling tests
 MyTest = None
@@ -3707,11 +3709,11 @@ class ListenerTest(fixtures.ORMTest):
                 classes[2], "attrib", uselist=False, useobject=False
             )
 
-        def set(state, value, oldvalue, initiator):
+        def set_(state, value, oldvalue, initiator):
             canary.append(value)
 
         def events_a():
-            event.listen(classes[0].attrib, "set", set, propagate=True)
+            event.listen(classes[0].attrib, "set", set_, propagate=True)
 
         def teardown():
             classes[:] = [None, None, None]
index 7faa650d72929db37dbf00e08554259987ebbe2f..8647ddb785d56da172aa6c883a982fecce5df8ff 100644 (file)
@@ -9,23 +9,15 @@ UPDATE in the database.
 
 """
 
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy import Integer, String, ForeignKey, Sequence, exc as sa_exc
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    class_mapper,
-    backref,
-    sessionmaker,
-    Session,
-)
-from sqlalchemy.orm import attributes, exc as orm_exc
 from sqlalchemy import testing
-from sqlalchemy.testing import eq_, is_
-from sqlalchemy.testing import fixtures
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import is_
 from test.orm import _fixtures
 
 
index 5c87d9429a8b97b0b2ff0deb35bc2cc936892057..3ca2c1021886d436a0c09098333f6af88cfecfce 100644 (file)
@@ -1,14 +1,23 @@
-from sqlalchemy.testing import assert_raises_message
-from sqlalchemy import MetaData, Integer, ForeignKey
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import mapper, create_session
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
 from sqlalchemy import testing
-from sqlalchemy.testing import fixtures, eq_, engines, is_
-from sqlalchemy.orm import relationship, Session, backref, sessionmaker
-from test.orm import _fixtures
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from test.orm import _fixtures
 
 
 class BindIntegrationTest(_fixtures.FixtureTest):
index 1d253a90782a68dbf6b49866d92ba19896f51bf4..7d591e906cbd34624d4a5f0dd805eff5980b1c12 100644 (file)
@@ -1,11 +1,16 @@
+from sqlalchemy import FetchedValue
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Session
 from sqlalchemy.testing import eq_
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.testing import mock
 from sqlalchemy.testing import fixtures
-from sqlalchemy import Integer, String, ForeignKey, FetchedValue
-from sqlalchemy.orm import mapper, Session
+from sqlalchemy.testing import mock
 from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm import _fixtures
 
 
index 9b27d247df5725a4f5f0502108ff7153646eca03..a17a00ed0dcdb9b433b759bcb8fa49da37bb2d8b 100644 (file)
@@ -1,10 +1,19 @@
-from sqlalchemy.testing import fixtures, eq_
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import Bundle, Session
-from sqlalchemy.testing import AssertsCompiledSQL
-from sqlalchemy import Integer, select, ForeignKey, String, func
-from sqlalchemy.orm import mapper, relationship, aliased
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import Bundle
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 from sqlalchemy.sql.elements import ClauseList
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class BundleTest(fixtures.MappedTest, AssertsCompiledSQL):
index 9aaf765927b59b105aaee4e1bc1a917b6f8b6e0b..1cd9d344ffc72a78d13f900270d8958a3c78aefd 100644 (file)
@@ -1,32 +1,32 @@
 import copy
 
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy import (
-    Integer,
-    String,
-    ForeignKey,
-    exc as sa_exc,
-    util,
-    select,
-    func,
-)
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    sessionmaker,
-    class_mapper,
-    backref,
-    Session,
-    util as orm_util,
-    configure_mappers,
-)
-from sqlalchemy.orm.attributes import instance_state
-from sqlalchemy.orm import attributes, exc as orm_exc, object_mapper
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
+from sqlalchemy import util
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import object_mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import util as orm_util
+from sqlalchemy.orm.attributes import instance_state
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm import _fixtures
 
 
@@ -226,7 +226,16 @@ class O2MCascadeDeleteOrphanTest(fixtures.MappedTest):
 
     @classmethod
     def setup_mappers(cls):
-        users, Dingaling, Order, User, dingalings, Address, orders, addresses = (
+        (
+            users,
+            Dingaling,
+            Order,
+            User,
+            dingalings,
+            Address,
+            orders,
+            addresses,
+        ) = (
             cls.tables.users,
             cls.classes.Dingaling,
             cls.classes.Order,
@@ -2145,8 +2154,8 @@ class M2MCascadeTest(fixtures.MappedTest):
             A,
             a,
             properties={
-                # if no backref here, delete-orphan failed until [ticket:427] was
-                # fixed
+                # if no backref here, delete-orphan failed until #
+                # [ticket:427] was fixed
                 "bs": relationship(
                     B,
                     secondary=atob,
@@ -3821,7 +3830,14 @@ class SubclassCascadeTest(fixtures.DeclarativeMappedTest):
             __mapper_args__ = {"polymorphic_identity": "java_language"}
 
     def test_cascade_iterator_polymorphic(self):
-        Company, Employee, Engineer, Language, JavaLanguage, MavenBuild = self.classes(
+        (
+            Company,
+            Employee,
+            Engineer,
+            Language,
+            JavaLanguage,
+            MavenBuild,
+        ) = self.classes(
             "Company",
             "Employee",
             "Engineer",
@@ -3854,7 +3870,14 @@ class SubclassCascadeTest(fixtures.DeclarativeMappedTest):
         eq_(set([rec[0] for rec in it]), set([maven_build, lang]))
 
     def test_delete_orphan_round_trip(self):
-        Company, Employee, Engineer, Language, JavaLanguage, MavenBuild = self.classes(
+        (
+            Company,
+            Employee,
+            Engineer,
+            Language,
+            JavaLanguage,
+            MavenBuild,
+        ) = self.classes(
             "Company",
             "Employee",
             "Engineer",
index 363104596fe57a8925d6459c9a91fb18fb013b74..3ff0129c0fc94eaeaf656a01aa3c04fd4366f601 100644 (file)
@@ -1,23 +1,27 @@
-from sqlalchemy.testing import eq_, ne_
 from operator import and_
 
+import sqlalchemy as sa
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import util
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import instrumentation
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 import sqlalchemy.orm.collections as collections
 from sqlalchemy.orm.collections import collection
-
-import sqlalchemy as sa
-from sqlalchemy import Integer, String, ForeignKey, text
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy import util, exc as sa_exc
-from sqlalchemy.orm import (
-    create_session,
-    mapper,
-    relationship,
-    attributes,
-    instrumentation,
-)
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy import testing
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class Canary(sa.orm.interfaces.AttributeExtension):
@@ -75,8 +79,8 @@ class CollectionsTest(fixtures.ORMTest):
 
     @classmethod
     def dictable_entity(cls, a=None, b=None, c=None):
-        id = cls._entity_id = cls._entity_id + 1
-        return cls.Entity(a or str(id), b or "value %s" % id, c)
+        id_ = cls._entity_id = cls._entity_id + 1
+        return cls.Entity(a or str(id_), b or "value %s" % id, c)
 
     def _test_adapter(self, typecallable, creator=None, to_set=None):
         if creator is None:
index 9ef346170ba17abeb2db51e1b117bbe669efba57..de8e19bad676ff56b9a3e58a06112cbb65da6d30 100644 (file)
@@ -1,9 +1,20 @@
-from sqlalchemy import *
+from sqlalchemy import Column
 from sqlalchemy import exc as sa_exc
-from sqlalchemy.orm import *
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import Unicode
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import fixtures
-from sqlalchemy import testing
 
 
 class CompileTest(fixtures.ORMTest):
index 5126964c98436ae43f57438a6ed5a5e5fce37b9d..3fef87a0ecfecbbdb3fbc64020ab845b66881aea 100644 (file)
@@ -1,18 +1,22 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey, select
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    CompositeProperty,
-    aliased,
-    persistence,
-)
-from sqlalchemy.orm import composite, Session, configure_mappers
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import composite
+from sqlalchemy.orm import CompositeProperty
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import persistence
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class PointTest(fixtures.MappedTest, testing.AssertsCompiledSQL):
@@ -492,8 +496,8 @@ class PrimaryKeyTest(fixtures.MappedTest):
         graphs = cls.tables.graphs
 
         class Version(cls.Comparable):
-            def __init__(self, id, version):
-                self.id = id
+            def __init__(self, id_, version):
+                self.id = id_
                 self.version = version
 
             def __composite_values__(self):
index 5f1c63f99914c9e877c84db6ddb6a9efab008947..8cf4e4b5c649c8479c7b7fe240d5b09a1a08a258 100644 (file)
@@ -5,24 +5,29 @@ T1<->T2, with o2m or m2o between them, and a third T3 with o2m/m2o to one/both
 T1/T2.
 
 """
-from sqlalchemy import testing
+from itertools import count
+
+from sqlalchemy import bindparam
 from sqlalchemy import event
-from sqlalchemy.testing import mock
-from sqlalchemy import Integer, String, ForeignKey
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    backref,
-    create_session,
-    sessionmaker,
-    Session,
-)
-from sqlalchemy.testing import eq_, is_
-from sqlalchemy.testing.assertsql import RegexSQL, CompiledSQL, AllOf
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from itertools import count
-from sqlalchemy import select
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import mock
+from sqlalchemy.testing.assertsql import AllOf
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.assertsql import RegexSQL
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class SelfReferentialTest(fixtures.MappedTest):
@@ -1679,9 +1684,6 @@ class PostUpdateBatchingTest(fixtures.MappedTest):
         )
 
 
-from sqlalchemy import bindparam
-
-
 class PostUpdateOnUpdateTest(fixtures.DeclarativeMappedTest):
     @classmethod
     def setup_classes(cls):
index 82ba7c4bb2f3cbdc0c1f006f706086860545f4b9..53309b282baaa5e2b163a2bab8ce23ba9ab67773 100644 (file)
@@ -1,9 +1,12 @@
-from test.orm import _fixtures
+import sqlalchemy as sa
 from sqlalchemy import testing
-from sqlalchemy.orm import mapper, relationship, create_session
 from sqlalchemy import util
-import sqlalchemy as sa
-from sqlalchemy.testing import eq_, assert_raises_message
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from test.orm import _fixtures
 
 
 class DefaultStrategyOptionsTest(_fixtures.FixtureTest):
@@ -36,7 +39,20 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest):
         self.assert_sql_count(testing.db, go, 0)
 
     def _downgrade_fixture(self):
-        users, Keyword, items, order_items, orders, Item, User, Address, keywords, item_keywords, Order, addresses = (
+        (
+            users,
+            Keyword,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            keywords,
+            item_keywords,
+            Order,
+            addresses,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.items,
@@ -97,7 +113,20 @@ class DefaultStrategyOptionsTest(_fixtures.FixtureTest):
         return create_session()
 
     def _upgrade_fixture(self):
-        users, Keyword, items, order_items, orders, Item, User, Address, keywords, item_keywords, Order, addresses = (
+        (
+            users,
+            Keyword,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            keywords,
+            item_keywords,
+            Order,
+            addresses,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.items,
index 878cc430bf85a532c30bcd5bdb5517f26bb39a74..40e72ad74057f056bc39d65933582b7be1712468 100644 (file)
@@ -1,10 +1,13 @@
 import sqlalchemy as sa
-from sqlalchemy import Integer, String, ForeignKey, event
-from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import mapper, relationship, create_session
-from sqlalchemy.testing import fixtures
+from sqlalchemy import event
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
 from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class TriggerDefaultsTest(fixtures.MappedTest):
index 29dd6947ea80b3190b7948c0c8b69f125ced197a..3c817285029410025e7b8e38cdc4b68bc7b917ff 100644 (file)
@@ -1,43 +1,38 @@
 import sqlalchemy as sa
-from sqlalchemy import testing, util
-from sqlalchemy.orm import (
-    mapper,
-    deferred,
-    defer,
-    undefer,
-    Load,
-    load_only,
-    undefer_group,
-    create_session,
-    synonym,
-    relationship,
-    Session,
-    joinedload,
-    defaultload,
-    aliased,
-    contains_eager,
-    with_polymorphic,
-    query_expression,
-    with_expression,
-    subqueryload,
-)
-from sqlalchemy.testing import eq_, AssertsCompiledSQL, assert_raises_message
-from test.orm import _fixtures
-from sqlalchemy.testing.schema import Column
-from sqlalchemy import Integer, ForeignKey
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import testing
+from sqlalchemy import util
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import contains_eager
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import defaultload
+from sqlalchemy.orm import defer
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import Load
+from sqlalchemy.orm import load_only
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import query_expression
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import synonym
+from sqlalchemy.orm import undefer
+from sqlalchemy.orm import undefer_group
+from sqlalchemy.orm import with_expression
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-
-
-from .inheritance._poly_fixtures import (
-    Company,
-    Person,
-    Engineer,
-    Manager,
-    Boss,
-    Machine,
-    Paperwork,
-    _Polymorphic,
-)
+from sqlalchemy.testing.schema import Column
+from test.orm import _fixtures
+from .inheritance._poly_fixtures import _Polymorphic
+from .inheritance._poly_fixtures import Boss
+from .inheritance._poly_fixtures import Company
+from .inheritance._poly_fixtures import Manager
+from .inheritance._poly_fixtures import Person
 
 
 class DeferredTest(AssertsCompiledSQL, _fixtures.FixtureTest):
@@ -594,10 +589,13 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest):
                     {"id_1": 7},
                 ),
                 (
-                    "SELECT orders.user_id AS orders_user_id, orders.description "
+                    "SELECT orders.user_id AS orders_user_id, "
+                    "orders.description "
                     "AS orders_description, orders.isopen AS orders_isopen, "
-                    "orders.id AS orders_id, orders.address_id AS orders_address_id "
-                    "FROM orders WHERE :param_1 = orders.user_id ORDER BY orders.id",
+                    "orders.id AS orders_id, orders.address_id "
+                    "AS orders_address_id "
+                    "FROM orders WHERE :param_1 = orders.user_id "
+                    "ORDER BY orders.id",
                     {"param_1": 7},
                 ),
             ],
@@ -654,10 +652,13 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest):
                     {"id_1": 7},
                 ),
                 (
-                    "SELECT orders.user_id AS orders_user_id, orders.description "
+                    "SELECT orders.user_id AS orders_user_id, "
+                    "orders.description "
                     "AS orders_description, orders.isopen AS orders_isopen, "
-                    "orders.id AS orders_id, orders.address_id AS orders_address_id, "
-                    "anon_1.users_id AS anon_1_users_id FROM (SELECT users.id AS "
+                    "orders.id AS orders_id, "
+                    "orders.address_id AS orders_address_id, "
+                    "anon_1.users_id AS anon_1_users_id "
+                    "FROM (SELECT users.id AS "
                     "users_id FROM users WHERE users.id = :id_1) AS anon_1 "
                     "JOIN orders ON anon_1.users_id = orders.user_id ORDER BY "
                     "anon_1.users_id, orders.id",
@@ -713,8 +714,9 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest):
             [
                 (
                     "SELECT users.id AS users_id, users.name AS users_name, "
-                    "orders_1.user_id AS orders_1_user_id, orders_1.description AS "
-                    "orders_1_description, orders_1.isopen AS orders_1_isopen, "
+                    "orders_1.user_id AS orders_1_user_id, "
+                    "orders_1.description AS orders_1_description, "
+                    "orders_1.isopen AS orders_1_isopen, "
                     "orders_1.id AS orders_1_id, orders_1.address_id AS "
                     "orders_1_address_id FROM users "
                     "LEFT OUTER JOIN orders AS orders_1 ON users.id = "
@@ -777,7 +779,8 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest):
                     "SELECT users.id AS users_id, users.name AS users_name, "
                     "orders_1.user_id AS orders_1_user_id, "
                     "lower(orders_1.description) AS lower_1, "
-                    "orders_1.isopen AS orders_1_isopen, orders_1.id AS orders_1_id, "
+                    "orders_1.isopen AS orders_1_isopen, "
+                    "orders_1.id AS orders_1_id, "
                     "orders_1.address_id AS orders_1_address_id, "
                     "orders_1.description AS orders_1_description FROM users "
                     "LEFT OUTER JOIN orders AS orders_1 ON users.id = "
@@ -1162,7 +1165,8 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest):
             "orders_1.id AS orders_1_id FROM users "
             "LEFT OUTER JOIN addresses AS addresses_1 "
             "ON users.id = addresses_1.user_id "
-            "LEFT OUTER JOIN orders AS orders_1 ON users.id = orders_1.user_id",
+            "LEFT OUTER JOIN orders AS orders_1 "
+            "ON users.id = orders_1.user_id",
         )
 
 
index fa051e88403d0e81e19348210e2d120e9e88b2b8..195012b9941f044a8aa5f699d07b8f7cb60f7419 100644 (file)
@@ -10,17 +10,23 @@ be migrated directly to the wiki, docs, etc.
     and in modern use illustrates trivial use cases that don't need
     an additional test suite.
 
-
 """
-from sqlalchemy import Integer, String, ForeignKey, func, text
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import mapper, relationship, create_session, sessionmaker
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import text
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import sessionmaker
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class QueryAlternativesTest(fixtures.MappedTest):
-    '''Collects modern idioms for Queries
+    r'''Collects modern idioms for Queries
 
     The docstring for each test case serves as miniature documentation about
     the deprecated use case, and the test body illustrates (and covers) the
@@ -30,22 +36,22 @@ class QueryAlternativesTest(fixtures.MappedTest):
     cases remain useful to readers even after the deprecated method has been
     removed from the modern codebase.
 
-    Format:
+    Format::
 
-    def test_deprecated_thing(self):
-        """Query.methodname(old, arg, **signature)
+        def test_deprecated_thing(self):
+            """Query.methodname(old, arg, **signature)
 
-        output = session.query(User).deprecatedmethod(inputs)
+            output = session.query(User).deprecatedmethod(inputs)
 
-        """
+            """
 
-        # 0.4+
-        output = session.query(User).newway(inputs)
-        assert output is correct
+            # 0.4+
+            output = session.query(User).newway(inputs)
+            assert output is correct
 
-        # 0.5+
-        output = session.query(User).evennewerway(inputs)
-        assert output is correct
+            # 0.5+
+            output = session.query(User).evennewerway(inputs)
+            assert output is correct
 
     '''
 
@@ -169,11 +175,11 @@ class QueryAlternativesTest(fixtures.MappedTest):
 
         # 0.5.0
         maxes = list(session.query(Address).values(func.max(Address.bounces)))
-        max = maxes[0][0]
-        assert max == 10
+        max_ = maxes[0][0]
+        assert max_ == 10
 
-        max = session.query(func.max(Address.bounces)).one()[0]
-        assert max == 10
+        max_ = session.query(func.max(Address.bounces)).one()[0]
+        assert max_ == 10
 
     def test_apply_min(self):
         """Query.apply_min(col)
@@ -188,11 +194,11 @@ class QueryAlternativesTest(fixtures.MappedTest):
 
         # 0.5.0
         mins = list(session.query(Address).values(func.min(Address.bounces)))
-        min = mins[0][0]
-        assert min == 0
+        min_ = mins[0][0]
+        assert min_ == 0
 
-        min = session.query(func.min(Address.bounces)).one()[0]
-        assert min == 0
+        min_ = session.query(func.min(Address.bounces)).one()[0]
+        assert min_ == 0
 
     def test_apply_avg(self):
         """Query.apply_avg(col)
@@ -231,7 +237,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert avg == 11
 
     def test_count_by(self):
-        """Query.count_by(*args, **params)
+        r"""Query.count_by(\*args, \**params)
 
         num = session.query(Address).count_by(purpose='Personal')
 
@@ -255,7 +261,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert num == 3, num
 
     def test_count_whereclause(self):
-        """Query.count(whereclause=None, params=None, **kwargs)
+        r"""Query.count(whereclause=None, params=None, \**kwargs)
 
         num = session.query(Address).count(address_table.c.bounces > 1)
 
@@ -269,7 +275,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert num == 1, num
 
     def test_execute(self):
-        """Query.execute(clauseelement, params=None, *args, **kwargs)
+        r"""Query.execute(clauseelement, params=None, \*args, \**kwargs)
 
         users = session.query(User).execute(users_table.select())
 
@@ -283,7 +289,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert len(users) == 4
 
     def test_get_by(self):
-        """Query.get_by(*args, **params)
+        r"""Query.get_by(\*args, \**params)
 
         user = session.query(User).get_by(name='ed')
 
@@ -316,7 +322,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert user.name == "fred"
 
     def test_instances_entities(self):
-        """Query.instances(cursor, *mappers_or_columns, **kwargs)
+        r"""Query.instances(cursor, \*mappers_or_columns, \**kwargs)
 
         sel = users_table.join(addresses_table).select(use_labels=True)
         res = session.query(User).instances(sel.execute(), Address)
@@ -340,7 +346,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert isinstance(cola, User) and isinstance(colb, Address)
 
     def test_join_by(self):
-        """Query.join_by(*args, **params)
+        r"""Query.join_by(\*args, \**params)
 
         TODO
         """
@@ -392,7 +398,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert user.id == 1
 
     def test_select(self):
-        """Query.select(arg=None, **kwargs)
+        r"""Query.select(arg=None, \**kwargs)
 
         users = session.query(User).select(users_table.c.name != None)
 
@@ -406,11 +412,11 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert len(users) == 4
 
     def test_select_by(self):
-        """Query.select_by(*args, **params)
+        r"""Query.select_by(\*args, \**params)
 
         users = session.query(User).select_by(name='fred')
 
-        # 0.3 magic join on *_by methods
+        # 0.3 magic join on \*_by methods
         users = session.query(User).select_by(email_address='fred@the.fred')
 
         """
@@ -442,7 +448,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert len(users) == 1
 
     def test_selectfirst(self):
-        """Query.selectfirst(arg=None, **kwargs)
+        r"""Query.selectfirst(arg=None, \**kwargs)
 
         bounced = session.query(Address).selectfirst(
           addresses_table.c.bounces > 0)
@@ -457,7 +463,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert bounced.bounces > 0
 
     def test_selectfirst_by(self):
-        """Query.selectfirst_by(*args, **params)
+        r"""Query.selectfirst_by(\*args, \**params)
 
         onebounce = session.query(Address).selectfirst_by(bounces=1)
 
@@ -491,7 +497,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert onebounce_user.name == "jack"
 
     def test_selectone(self):
-        """Query.selectone(arg=None, **kwargs)
+        r"""Query.selectone(arg=None, \**kwargs)
 
         ed = session.query(User).selectone(users_table.c.name == 'ed')
 
@@ -535,7 +541,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         )
 
     def test_select_statement(self):
-        """Query.select_statement(statement, **params)
+        r"""Query.select_statement(statement, \**params)
 
         users = session.query(User).select_statement(users_table.select())
 
@@ -549,7 +555,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert len(users) == 4
 
     def test_select_text(self):
-        """Query.select_text(text, **params)
+        r"""Query.select_text(text, \**params)
 
         users = session.query(User).select_text('SELECT * FROM users_table')
 
@@ -567,7 +573,7 @@ class QueryAlternativesTest(fixtures.MappedTest):
         assert len(users) == 4
 
     def test_select_whereclause(self):
-        """Query.select_whereclause(whereclause=None, params=None, **kwargs)
+        r"""Query.select_whereclause(whereclause=None, params=None, \**kwargs)
 
 
         users = session,query(User).select_whereclause(users.c.name=='ed')
index 798d2af544748b049f60b559f0f461f04d94274e..1baa82d3d277d431908629c83e9cc327550a7d16 100644 (file)
@@ -1,12 +1,16 @@
-from sqlalchemy.orm import descriptor_props, aliased
+from sqlalchemy import Column
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import descriptor_props
 from sqlalchemy.orm.interfaces import PropComparator
 from sqlalchemy.orm.properties import ColumnProperty
 from sqlalchemy.sql import column
-from sqlalchemy import Column, Integer, func, String
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.util import partial
-from sqlalchemy.testing import fixtures
 from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.util import partial
 
 
 class TestDescriptor(descriptor_props.DescriptorProperty):
index 09252dda3240143d42006d6659648b815e2442ed..b861a9fe5728bb9e08874fe446d0aeb987ed38bb 100644 (file)
@@ -1,25 +1,27 @@
-from sqlalchemy import testing, desc, select, func, exc, cast, Integer
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    Query,
-    attributes,
-    exc as orm_exc,
-    Session,
-    backref,
-    configure_mappers,
-)
+from sqlalchemy import cast
+from sqlalchemy import desc
+from sqlalchemy import exc
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import testing
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Query
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 from sqlalchemy.orm.dynamic import AppenderMixin
-from sqlalchemy.testing import (
-    AssertsCompiledSQL,
-    assert_raises_message,
-    assert_raises,
-    eq_,
-    is_,
-)
-from test.orm import _fixtures
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import is_
 from sqlalchemy.testing.assertsql import CompiledSQL
+from test.orm import _fixtures
 
 
 class _DynamicFixture(object):
@@ -740,16 +742,16 @@ class UOWTest(
             eq_(
                 testing.db.scalar(
                     select([func.count("*")]).where(
-                        addresses.c.user_id == None  # noqa
-                    )
+                        addresses.c.user_id == None
+                    )  # noqa
                 ),
                 6,
             )
             eq_(
                 testing.db.scalar(
                     select([func.count("*")]).where(
-                        addresses.c.user_id != None  # noqa
-                    )
+                        addresses.c.user_id != None
+                    )  # noqa
                 ),
                 0,
             )
index b38f23529d18199f60878fc4bd798a92d00d909f..2b53e5ae81e314ef1c868cdaf43ad9462fd67b89 100644 (file)
@@ -1,46 +1,47 @@
 """tests of joined-eager loaded attributes"""
 
-from sqlalchemy.testing import eq_, is_, is_not_, in_
+import datetime
+
 import sqlalchemy as sa
+from sqlalchemy import and_
+from sqlalchemy import Date
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.orm import (
-    joinedload,
-    deferred,
-    undefer,
-    joinedload_all,
-    backref,
-    Session,
-    defaultload,
-    Load,
-    load_only,
-    contains_eager,
-)
-from sqlalchemy import (
-    Integer,
-    String,
-    Date,
-    ForeignKey,
-    and_,
-    select,
-    func,
-    text,
-)
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    lazyload,
-    aliased,
-    column_property,
-)
+from sqlalchemy import text
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import contains_eager
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import defaultload
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import lazyload
+from sqlalchemy.orm import Load
+from sqlalchemy.orm import load_only
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import undefer
 from sqlalchemy.sql import operators
-from sqlalchemy.testing import assert_raises, assert_raises_message
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import in_
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
 from sqlalchemy.testing.assertsql import CompiledSQL
-from sqlalchemy.testing import fixtures, expect_warnings
-from test.orm import _fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from sqlalchemy.util import OrderedDict as odict
-import datetime
+from test.orm import _fixtures
 
 
 class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@@ -492,7 +493,18 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         self.assert_sql_count(testing.db, go, 1)
 
     def test_options_pathing(self):
-        users, Keyword, orders, items, order_items, Order, Item, User, keywords, item_keywords = (
+        (
+            users,
+            Keyword,
+            orders,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            keywords,
+            item_keywords,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.orders,
@@ -794,7 +806,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         """Eager loading with two relationships simultaneously,
         from the same table, using aliases."""
 
-        addresses, items, order_items, orders, Item, User, Address, Order, users = (
+        (
+            addresses,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            users,
+        ) = (
             self.tables.addresses,
             self.tables.items,
             self.tables.order_items,
@@ -939,7 +961,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
     def test_limit(self):
         """Limit operations combined with lazy-load relationships."""
 
-        users, items, order_items, orders, Item, User, Address, Order, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
@@ -1074,7 +1106,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         'wrapped' select statement resulting from the combination of
         eager loading and limit/offset clauses."""
 
-        addresses, items, order_items, orders, Item, User, Address, Order, users = (
+        (
+            addresses,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            users,
+        ) = (
             self.tables.addresses,
             self.tables.items,
             self.tables.order_items,
@@ -1305,7 +1347,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         """test that the subquery wrapping only occurs with
         limit/offset and m2m or o2m joins present."""
 
-        users, items, order_items, Order, Item, User, Address, orders, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            Address,
+            orders,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
@@ -1739,7 +1791,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         )
 
     def test_wide(self):
-        users, items, order_items, Order, Item, User, Address, orders, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            Address,
+            orders,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
@@ -2272,7 +2334,18 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         # test eager join chaining to the "nested" join on the left,
         # a new feature as of [ticket:2369]
 
-        users, Keyword, orders, items, order_items, Order, Item, User, keywords, item_keywords = (
+        (
+            users,
+            Keyword,
+            orders,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            keywords,
+            item_keywords,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.orders,
@@ -2289,8 +2362,8 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
             User,
             users,
             properties={
-                "orders": relationship(Order, backref="user")  # o2m, m2o
-            },
+                "orders": relationship(Order, backref="user")
+            },  # o2m, m2o
         )
         mapper(
             Order,
@@ -3475,7 +3548,17 @@ class AddEntityTest(_fixtures.FixtureTest):
         ]
 
     def test_mapper_configured(self):
-        users, items, order_items, Order, Item, User, Address, orders, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            Address,
+            orders,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
@@ -3525,7 +3608,17 @@ class AddEntityTest(_fixtures.FixtureTest):
         self.assert_sql_count(testing.db, go, 1)
 
     def test_options(self):
-        users, items, order_items, Order, Item, User, Address, orders, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            Address,
+            orders,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
@@ -4162,7 +4255,20 @@ class MixedEntitiesTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
 
     @classmethod
     def setup_mappers(cls):
-        users, Keyword, items, order_items, orders, Item, User, Address, keywords, Order, item_keywords, addresses = (
+        (
+            users,
+            Keyword,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            keywords,
+            Order,
+            item_keywords,
+            addresses,
+        ) = (
             cls.tables.users,
             cls.classes.Keyword,
             cls.tables.items,
index 651c81a85876c7c287b4ec0544b7ab43384bcddd..5bc05448653bff60a37a1284f638308b4094eb2c 100644 (file)
@@ -1,21 +1,24 @@
 """Evaluating SQL expressions on ORM objects"""
 
-from sqlalchemy import String, Integer, bindparam
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.testing import fixtures
-
-from sqlalchemy import and_, or_, not_
+from sqlalchemy import and_
+from sqlalchemy import bindparam
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import not_
+from sqlalchemy import or_
+from sqlalchemy import String
 from sqlalchemy.orm import evaluator
 from sqlalchemy.orm import mapper
-
-from sqlalchemy.orm import relationship, Session
-from sqlalchemy import ForeignKey
-from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 from sqlalchemy.testing import assert_raises_message
-from sqlalchemy.testing import is_
-from sqlalchemy import inspect
 from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+
 
 compiler = evaluator.EvaluatorCompiler()
 
index 1390da497986c2ff0a6b0d8c720fd3e1441f4117..bb1a935de3740679d69f56d328aa37f0ef08f60a 100644 (file)
@@ -1,33 +1,37 @@
-from sqlalchemy.testing import assert_raises_message, assert_raises
 import sqlalchemy as sa
+from sqlalchemy import event
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String
 from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    class_mapper,
-    Mapper,
-    column_property,
-    query,
-    Session,
-    sessionmaker,
-    attributes,
-    configure_mappers,
-)
-from sqlalchemy.orm.instrumentation import ClassManager
-from sqlalchemy.orm import instrumentation, events
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import events
 from sqlalchemy.orm import EXT_SKIP
+from sqlalchemy.orm import instrumentation
+from sqlalchemy.orm import Mapper
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import query
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
 from sqlalchemy.orm.mapper import _mapper_registry
-from sqlalchemy.testing import eq_, is_not_, assert_raises
-from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_not_
+from sqlalchemy.testing.mock import ANY
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from sqlalchemy.testing.util import gc_collect
 from test.orm import _fixtures
-from sqlalchemy import event
-from sqlalchemy.testing.mock import Mock, call, ANY
 
 
 class _RemoveListeners(object):
@@ -167,7 +171,12 @@ class MapperEventsTest(_RemoveListeners, _fixtures.FixtureTest):
         m = mapper(
             User,
             users,
-            properties={"addresses": relationship(lambda: ImNotAClass)},
+            properties={
+                # intentionally non-existent class to ensure
+                # the lambda is not called, simulates a class from
+                # a not-yet-imported module
+                "addresses": relationship(lambda: ImNotAClass)  # noqa
+            },
         )
         event.listen(User, "before_insert", lambda *a, **kw: None)
         assert not m.configured
index 875ebd31de23b85ca26f963096455a549f06d9eb..03ef7b03abfb8ef56cc836eccb6a1103db0ce82a 100644 (file)
@@ -1,31 +1,33 @@
 """Attribute/instance expiration, deferral of attributes, etc."""
 
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message
-from sqlalchemy.testing.util import gc_collect
 import sqlalchemy as sa
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import FetchedValue
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey, exc as sa_exc, FetchedValue
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    attributes,
-    deferred,
-    exc as orm_exc,
-    defer,
-    undefer,
-    strategies,
-    state,
-    lazyload,
-    backref,
-    Session,
-)
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import defer
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import lazyload
+from sqlalchemy.orm import make_transient_to_detached
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import strategies
+from sqlalchemy.orm import undefer
+from sqlalchemy.sql import select
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import gc_collect
 from test.orm import _fixtures
-from sqlalchemy.sql import select
-from sqlalchemy.orm import make_transient_to_detached
 
 
 class ExpireTest(_fixtures.FixtureTest):
@@ -1395,7 +1397,7 @@ class PolymorphicExpireTest(fixtures.MappedTest):
         sess.add(e1)
         assert e1.name == "engineer1"
 
-    def test_no_instance_key(self):
+    def test_no_instance_key_pk_absent(self):
         Engineer = self.classes.Engineer
 
         # same as test_no_instance_key, but the PK columns
index 06403875012eb681e506eef428319ac6c45e8346..9b68136bdd5c8c4ce0cbc2fbb7b51cb02d349a7b 100644 (file)
@@ -1,55 +1,48 @@
+import sqlalchemy as sa
+from sqlalchemy import and_
+from sqlalchemy import asc
+from sqlalchemy import cast
+from sqlalchemy import desc
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import exists
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import literal_column
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.testing import (
-    fixtures,
-    eq_,
-    is_,
-    assert_raises,
-    assert_raises_message,
-    AssertsCompiledSQL,
-)
-from sqlalchemy import (
-    exc as sa_exc,
-    util,
-    Integer,
-    Table,
-    String,
-    ForeignKey,
-    select,
-    func,
-    and_,
-    asc,
-    desc,
-    inspect,
-    literal_column,
-    cast,
-    exists,
-    text,
-)
-from sqlalchemy.orm import (
-    configure_mappers,
-    Session,
-    mapper,
-    create_session,
-    relationship,
-    column_property,
-    joinedload_all,
-    contains_eager,
-    contains_alias,
-    joinedload,
-    clear_mappers,
-    backref,
-    relation,
-    aliased,
-)
-from sqlalchemy.sql import table, column
+from sqlalchemy import text
+from sqlalchemy import util
 from sqlalchemy.engine import default
-import sqlalchemy as sa
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import contains_alias
+from sqlalchemy.orm import contains_eager
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relation
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm.util import join
+from sqlalchemy.sql import column
+from sqlalchemy.sql import table
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 from sqlalchemy.testing.schema import Column
-
 from test.orm import _fixtures
 
-from sqlalchemy.orm.util import join
-
 
 class QueryTest(_fixtures.FixtureTest):
     run_setup_mappers = "once"
@@ -58,7 +51,26 @@ class QueryTest(_fixtures.FixtureTest):
 
     @classmethod
     def setup_mappers(cls):
-        Node, composite_pk_table, users, Keyword, items, Dingaling, order_items, item_keywords, Item, User, dingalings, Address, keywords, CompositePk, nodes, Order, orders, addresses = (
+        (
+            Node,
+            composite_pk_table,
+            users,
+            Keyword,
+            items,
+            Dingaling,
+            order_items,
+            item_keywords,
+            Item,
+            User,
+            dingalings,
+            Address,
+            keywords,
+            CompositePk,
+            nodes,
+            Order,
+            orders,
+            addresses,
+        ) = (
             cls.classes.Node,
             cls.tables.composite_pk_table,
             cls.tables.users,
index 0e66172a3d4614c96048f3ee3f22f2e68560cf85..abc666af195e193f56d65022d448a03d505f9370 100644 (file)
@@ -1,12 +1,15 @@
-from sqlalchemy.testing import eq_
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey, MetaData, func
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import mapper, relationship, create_session
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm import _fixtures
 
 
@@ -155,7 +158,7 @@ class GenerativeQueryTest(fixtures.MappedTest):
         assert query.order_by(Foo.bar)[0].bar == 0
         assert query.order_by(sa.desc(Foo.bar))[0].bar == 99
 
-    def test_offset(self):
+    def test_offset_order_by(self):
         Foo = self.classes.Foo
 
         query = create_session().query(Foo)
index fe5e05a174fc7e9076f40c9f383fc5cbac25008f..d3a2bf20360083ac8cd35953ffdeb4ba4c63daad 100644 (file)
@@ -1,23 +1,19 @@
 """test the current state of the hasparent() flag."""
 
 
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy import Integer, String, ForeignKey, Sequence, exc as sa_exc
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    sessionmaker,
-    class_mapper,
-    backref,
-    Session,
-)
-from sqlalchemy.orm import attributes, exc as orm_exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
 from sqlalchemy import testing
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from test.orm import _fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from sqlalchemy.testing.util import gc_collect
 
 
index 6a3beeb792eb2c5a77649649fa75e2c586bc276e..2fdf1afd9cd405656166ec881a3dc1ed457c8477 100644 (file)
@@ -1,7 +1,9 @@
 """basic tests of lazy loaded attributes"""
 
-from sqlalchemy import testing
-from sqlalchemy.orm import mapper, relationship, create_session, immediateload
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import immediateload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import eq_
 from test.orm import _fixtures
 
index 2c641d026ee7ed3cdd33a5cc5e74af8bbbeb9e93..ca127580dc4234fb131668bd8146143c2f859ecd 100644 (file)
@@ -1,20 +1,21 @@
 """test the inspection registry system."""
 
-from sqlalchemy.testing import eq_, assert_raises_message, is_
-from sqlalchemy import exc, util
-from sqlalchemy import inspect
-from test.orm import _fixtures
-from sqlalchemy.orm import (
-    class_mapper,
-    synonym,
-    Session,
-    aliased,
-    relationship,
-)
+from sqlalchemy import exc
 from sqlalchemy import ForeignKey
-from sqlalchemy.orm.attributes import instance_state, NO_VALUE
+from sqlalchemy import inspect
 from sqlalchemy import testing
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import synonym
+from sqlalchemy.orm.attributes import instance_state
+from sqlalchemy.orm.attributes import NO_VALUE
 from sqlalchemy.orm.util import identity_key
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import is_
+from test.orm import _fixtures
 
 
 class TestORMInspection(_fixtures.FixtureTest):
index b6ed1e42b09e15523b6a31c9f9a0675cc0c30f55..6c2c8e5f81d3f4a1a2314e1bff6199ebc9d06951 100644 (file)
@@ -1,21 +1,22 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message
 import sqlalchemy as sa
-from sqlalchemy import MetaData, Integer, ForeignKey, util, event
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    attributes,
-    class_mapper,
-    clear_mappers,
-    instrumentation,
-    events,
-)
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.testing import eq_, ne_
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import util
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import instrumentation
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy import testing
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class InitTest(fixtures.ORMTest):
index 976b5650e0b74a0418dedad4c62790672c76b63b..5aefe61cccd7e9601e0d17ec8f8f732775e48554 100644 (file)
@@ -1,24 +1,39 @@
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message
-import operator
-from sqlalchemy import *
-from sqlalchemy import exc as sa_exc, util
-from sqlalchemy.sql import compiler, table, column
+import sqlalchemy as sa
+from sqlalchemy import and_
+from sqlalchemy import desc
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import lateral
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import not_
+from sqlalchemy import or_
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import true
 from sqlalchemy.engine import default
-from sqlalchemy.orm import *
-from sqlalchemy.orm import attributes
-
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import join
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import outerjoin
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import synonym
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
 from sqlalchemy.testing import eq_
-
-import sqlalchemy as sa
-from sqlalchemy import testing
-from sqlalchemy.testing import AssertsCompiledSQL, engines
+from sqlalchemy.testing import fixtures
 from sqlalchemy.testing.schema import Column
 from test.orm import _fixtures
 
-from sqlalchemy.testing import fixtures
-
-from sqlalchemy.orm.util import join, outerjoin, with_parent
-
 
 class QueryTest(_fixtures.FixtureTest):
     run_setup_mappers = "once"
@@ -27,7 +42,26 @@ class QueryTest(_fixtures.FixtureTest):
 
     @classmethod
     def setup_mappers(cls):
-        Node, composite_pk_table, users, Keyword, items, Dingaling, order_items, item_keywords, Item, User, dingalings, Address, keywords, CompositePk, nodes, Order, orders, addresses = (
+        (
+            Node,
+            composite_pk_table,
+            users,
+            Keyword,
+            items,
+            Dingaling,
+            order_items,
+            item_keywords,
+            Item,
+            User,
+            dingalings,
+            Address,
+            keywords,
+            CompositePk,
+            nodes,
+            Order,
+            orders,
+            addresses,
+        ) = (
             cls.classes.Node,
             cls.tables.composite_pk_table,
             cls.tables.users,
@@ -748,7 +782,8 @@ class JoinTest(QueryTest, AssertsCompiledSQL):
         self.assert_compile(
             sess.query(User).join(oalias1.user),
             "SELECT users.id AS users_id, users.name AS users_name "
-            "FROM orders AS orders_1 JOIN users ON users.id = orders_1.user_id",
+            "FROM orders AS orders_1 JOIN users "
+            "ON users.id = orders_1.user_id",
         )
 
     def test_single_prop_4(self):
@@ -964,15 +999,15 @@ class JoinTest(QueryTest, AssertsCompiledSQL):
     def test_overlapping_paths(self):
         User = self.classes.User
 
-        for aliased in (True, False):
+        for aliased_ in (True, False):
             # load a user who has an order that contains item id 3 and address
             # id 1 (order 3, owned by jack)
             result = (
                 create_session()
                 .query(User)
-                .join("orders", "items", aliased=aliased)
+                .join("orders", "items", aliased=aliased_)
                 .filter_by(id=3)
-                .join("orders", "address", aliased=aliased)
+                .join("orders", "address", aliased=aliased_)
                 .filter_by(id=1)
                 .all()
             )
@@ -1375,7 +1410,8 @@ class JoinTest(QueryTest, AssertsCompiledSQL):
             "SELECT users.id AS users_id, users.name AS users_name, "
             "users_1.id AS users_1_id, users_1.name AS users_1_name "
             "FROM users, "
-            "users AS users_1 JOIN addresses ON users_1.id = addresses.user_id",
+            "users AS users_1 JOIN addresses "
+            "ON users_1.id = addresses.user_id",
         )
 
     def test_join_explicit_left_multiple_adapted(self):
@@ -1408,7 +1444,8 @@ class JoinTest(QueryTest, AssertsCompiledSQL):
             "SELECT users_1.id AS users_1_id, users_1.name AS users_1_name, "
             "users_2.id AS users_2_id, users_2.name AS users_2_name "
             "FROM users AS users_1, "
-            "users AS users_2 JOIN addresses ON users_2.id = addresses.user_id",
+            "users AS users_2 JOIN addresses "
+            "ON users_2.id = addresses.user_id",
         )
 
     def test_join_entity_from_multiple_from_clause(self):
@@ -2053,16 +2090,16 @@ class JoinTest(QueryTest, AssertsCompiledSQL):
     def test_reset_joinpoint(self):
         User = self.classes.User
 
-        for aliased in (True, False):
+        for aliased_ in (True, False):
             # load a user who has an order that contains item id 3 and address
             # id 1 (order 3, owned by jack)
             result = (
                 create_session()
                 .query(User)
-                .join("orders", "items", aliased=aliased)
+                .join("orders", "items", aliased=aliased_)
                 .filter_by(id=3)
                 .reset_joinpoint()
-                .join("orders", "address", aliased=aliased)
+                .join("orders", "address", aliased=aliased_)
                 .filter_by(id=1)
                 .all()
             )
@@ -2071,10 +2108,10 @@ class JoinTest(QueryTest, AssertsCompiledSQL):
             result = (
                 create_session()
                 .query(User)
-                .join("orders", "items", aliased=aliased, isouter=True)
+                .join("orders", "items", aliased=aliased_, isouter=True)
                 .filter_by(id=3)
                 .reset_joinpoint()
-                .join("orders", "address", aliased=aliased, isouter=True)
+                .join("orders", "address", aliased=aliased_, isouter=True)
                 .filter_by(id=1)
                 .all()
             )
@@ -2083,10 +2120,10 @@ class JoinTest(QueryTest, AssertsCompiledSQL):
             result = (
                 create_session()
                 .query(User)
-                .outerjoin("orders", "items", aliased=aliased)
+                .outerjoin("orders", "items", aliased=aliased_)
                 .filter_by(id=3)
                 .reset_joinpoint()
-                .outerjoin("orders", "address", aliased=aliased)
+                .outerjoin("orders", "address", aliased=aliased_)
                 .filter_by(id=1)
                 .all()
             )
index 566317f0bf2235feb4fde35613a2a0c13bde8f53..4d9e460f9ad5009735b8c48725a72bd5ecbd4909 100644 (file)
@@ -1,23 +1,37 @@
 """basic tests of lazy loaded attributes"""
 
-from sqlalchemy.testing import assert_raises
 import datetime
-from sqlalchemy.orm import attributes, exc as orm_exc, configure_mappers
+
 import sqlalchemy as sa
-from sqlalchemy.orm.interfaces import MapperOption
-from sqlalchemy import testing, and_, bindparam
-from sqlalchemy import Integer, String, ForeignKey, SmallInteger, Boolean
+from sqlalchemy import and_
+from sqlalchemy import bindparam
+from sqlalchemy import Boolean
+from sqlalchemy import ForeignKey
 from sqlalchemy import ForeignKeyConstraint
-from sqlalchemy.types import TypeDecorator
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
+from sqlalchemy import Integer
 from sqlalchemy import orm
-from sqlalchemy.orm import mapper, relationship, create_session, Session
-from sqlalchemy.testing import eq_, is_true, is_false
+from sqlalchemy import SmallInteger
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm.interfaces import MapperOption
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from test.orm import _fixtures
-from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing import is_false
+from sqlalchemy.testing import is_true
 from sqlalchemy.testing import mock
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.types import TypeDecorator
+from test.orm import _fixtures
 
 
 class LazyTest(_fixtures.FixtureTest):
@@ -218,7 +232,17 @@ class LazyTest(_fixtures.FixtureTest):
     def test_limit(self):
         """test limit operations combined with lazy-load relationships."""
 
-        users, items, order_items, orders, Item, User, Address, Order, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
@@ -262,7 +286,17 @@ class LazyTest(_fixtures.FixtureTest):
             assert self.static.user_all_result[1:3] == result
 
     def test_distinct(self):
-        users, items, order_items, orders, Item, User, Address, Order, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
index 78a22ac54c079ef443555175a2b3e5233c3b262b..6e9dde16b0dce828cf153f2abe2219ae14f65b19 100644 (file)
@@ -1,13 +1,16 @@
-from sqlalchemy import *
-from sqlalchemy.orm import *
-
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.testing import eq_, AssertsExecutionResults, assert_raises
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import fixtures
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 from sqlalchemy.orm.attributes import instance_state
-from sqlalchemy.orm.exc import FlushError
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+
 
 engine = testing.db
 
@@ -180,7 +183,7 @@ class LoadOnFKsTest(AssertsExecutionResults, fixtures.TestBase):
         # pendings don't autoflush
         assert c3.parent is None
 
-    def test_autoflush_on_pending(self):
+    def test_autoflush_load_on_pending_on_pending(self):
         Child.parent.property.load_on_pending = True
         c3 = Child()
         sess.add(c3)
index bad4092ce21dba2f7843bc5a5e911b3148c7d33c..d263b12f2c64d02960651d117c09868b6ed3f9af 100644 (file)
@@ -1,14 +1,15 @@
-from . import _fixtures
-from sqlalchemy.orm import loading, Session, aliased
-from sqlalchemy.testing.assertions import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-)
-from sqlalchemy.util import KeyedTuple
-from sqlalchemy.testing import mock
-from sqlalchemy import select
 from sqlalchemy import exc
+from sqlalchemy import select
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import loading
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import mock
+from sqlalchemy.testing.assertions import assert_raises
+from sqlalchemy.testing.assertions import assert_raises_message
+from sqlalchemy.testing.assertions import eq_
+from sqlalchemy.util import KeyedTuple
+from . import _fixtures
+
 
 # class GetFromIdentityTest(_fixtures.FixtureTest):
 # class LoadOnIdentTest(_fixtures.FixtureTest):
index 1a05ffbe4d52cf056a51183e843a4567245084b2..dd928f0dbd3f2b2e6cc1ea533e77b54c1658b804 100644 (file)
@@ -1,14 +1,14 @@
+from sqlalchemy import exc
+from sqlalchemy import testing
 from sqlalchemy.engine import default
-from sqlalchemy.databases import *
-from sqlalchemy.orm import mapper
-from sqlalchemy.orm import Session
 from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
 from sqlalchemy.orm import relationship
-from sqlalchemy.testing import AssertsCompiledSQL, eq_
+from sqlalchemy.orm import Session
 from sqlalchemy.testing import assert_raises_message
-from sqlalchemy import exc
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
 from test.orm import _fixtures
-from sqlalchemy import testing
 
 
 class LegacyLockModeTest(_fixtures.FixtureTest):
index 3401de7faaab7c1710f81362adc5d38d3c3c7414..226415e34bc99ae9affc5710523b2ab7ba50359b 100644 (file)
@@ -1,18 +1,19 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message, eq_
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    Session,
-    exc as orm_exc,
-    sessionmaker,
-    backref,
-)
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class M2MTest(fixtures.MappedTest):
@@ -230,7 +231,16 @@ class M2MTest(fixtures.MappedTest):
         """test that a mapper can have two eager relationships to the same table, via
         two different association tables.  aliases are required."""
 
-        place_input, transition, Transition, PlaceThingy, place, place_thingy, Place, place_output = (
+        (
+            place_input,
+            transition,
+            Transition,
+            PlaceThingy,
+            place,
+            place_thingy,
+            Place,
+            place_output,
+        ) = (
             self.tables.place_input,
             self.tables.transition,
             self.classes.Transition,
index 780272cf762fe5bccdfc8725dfe74a3a8adb3fd7..47710792e72404d1580a8e8f0ecd43fe39e01169 100644 (file)
@@ -1,44 +1,45 @@
 """General mapper operations with an emphasis on selecting/loading."""
 
-from sqlalchemy.testing import assert_raises, assert_raises_message
+import logging
+import logging.handlers
+
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import (
-    MetaData,
-    Integer,
-    String,
-    ForeignKey,
-    func,
-    util,
-    select,
-)
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy import util
 from sqlalchemy.engine import default
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    backref,
-    create_session,
-    class_mapper,
-    configure_mappers,
-    reconstructor,
-    aliased,
-    deferred,
-    synonym,
-    attributes,
-    column_property,
-    composite,
-    dynamic_loader,
-    comparable_property,
-    Session,
-)
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import comparable_property
+from sqlalchemy.orm import composite
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import dynamic_loader
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import reconstructor
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import synonym
 from sqlalchemy.orm.persistence import _sort_states
-from sqlalchemy.testing import eq_, AssertsCompiledSQL, is_
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from test.orm import _fixtures
+from sqlalchemy.testing import is_
 from sqlalchemy.testing.assertsql import CompiledSQL
-import logging
-import logging.handlers
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from test.orm import _fixtures
 
 
 class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL):
@@ -325,8 +326,8 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL):
         """
 
         class Foo(object):
-            def __init__(self, id):
-                self.id = id
+            def __init__(self, id_):
+                self.id = id_
 
         m = MetaData()
         foo_t = Table("foo", m, Column("id", String, primary_key=True))
@@ -336,10 +337,10 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL):
             if util.py2k:
 
                 def __lt__(self, other):
-                    assert not isinstance(other, basestring)
+                    assert not isinstance(other, basestring)  # noqa
                     return int(self) < other
 
-        foos = [Foo(id="f%d" % i) for i in range(5)]
+        foos = [Foo(id_="f%d" % i) for i in range(5)]
         states = [attributes.instance_state(f) for f in foos]
 
         for s in states[0:3]:
@@ -2536,7 +2537,20 @@ class OptionsTest(_fixtures.FixtureTest):
         self.sql_count_(4, go)
 
     def test_eager_degrade_deep(self):
-        users, Keyword, items, order_items, orders, Item, User, Address, keywords, item_keywords, Order, addresses = (
+        (
+            users,
+            Keyword,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            keywords,
+            item_keywords,
+            Order,
+            addresses,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.items,
@@ -2689,7 +2703,18 @@ class OptionsTest(_fixtures.FixtureTest):
 class DeepOptionsTest(_fixtures.FixtureTest):
     @classmethod
     def setup_mappers(cls):
-        users, Keyword, items, order_items, Order, Item, User, keywords, item_keywords, orders = (
+        (
+            users,
+            Keyword,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            keywords,
+            item_keywords,
+            orders,
+        ) = (
             cls.tables.users,
             cls.classes.Keyword,
             cls.tables.items,
@@ -3312,10 +3337,8 @@ class DeferredPopulationTest(fixtures.MappedTest):
 
         session = create_session()
         human = (
-            session.query(Human)
-            .options(sa.orm.joinedload("thing"))  # noqa
-            .first()
-        )
+            session.query(Human).options(sa.orm.joinedload("thing")).first()
+        )  # noqa
         session.expunge_all()
         thing = session.query(Thing).options(sa.orm.undefer("name")).first()
         self._test(thing)
@@ -3325,10 +3348,8 @@ class DeferredPopulationTest(fixtures.MappedTest):
 
         session = create_session()
         human = (
-            session.query(Human)
-            .options(sa.orm.joinedload("thing"))  # noqa
-            .first()
-        )
+            session.query(Human).options(sa.orm.joinedload("thing")).first()
+        )  # noqa
         thing = session.query(Thing).options(sa.orm.undefer("name")).first()
         self._test(thing)
 
@@ -3337,11 +3358,8 @@ class DeferredPopulationTest(fixtures.MappedTest):
 
         session = create_session()
         result = (
-            session.query(Human)
-            .add_entity(Thing)  # noqa
-            .join("thing")
-            .first()
-        )
+            session.query(Human).add_entity(Thing).join("thing").first()
+        )  # noqa
         session.expunge_all()
         thing = session.query(Thing).options(sa.orm.undefer("name")).first()
         self._test(thing)
@@ -3351,11 +3369,8 @@ class DeferredPopulationTest(fixtures.MappedTest):
 
         session = create_session()
         result = (
-            session.query(Human)
-            .add_entity(Thing)  # noqa
-            .join("thing")
-            .first()
-        )
+            session.query(Human).add_entity(Thing).join("thing").first()
+        )  # noqa
         thing = session.query(Thing).options(sa.orm.undefer("name")).first()
         self._test(thing)
 
@@ -3714,8 +3729,8 @@ class RequirementsTest(fixtures.MappedTest):
             #  sa.exc.ArgumentError, mapper, NoWeakrefSupport, t2)
 
     class _ValueBase(object):
-        def __init__(self, value="abc", id=None):
-            self.id = id
+        def __init__(self, value="abc", id_=None):
+            self.id = id_
             self.value = value
 
         def __bool__(self):
@@ -3842,15 +3857,15 @@ class RequirementsTest(fixtures.MappedTest):
         ht2, ht1 = (self.tables.ht2, self.tables.ht1)
 
         class H1(self._ValueBase):
-            def __init__(self, value, id, h2s):
+            def __init__(self, value, id_, h2s):
                 self.value = value
-                self.id = id
+                self.id = id_
                 self.h2s = h2s
 
         class H2(self._ValueBase):
-            def __init__(self, value, id):
+            def __init__(self, value, id_):
                 self.value = value
-                self.id = id
+                self.id = id_
 
         mapper(H1, ht1, properties={"h2s": relationship(H2, backref="h1")})
         mapper(H2, ht2)
@@ -3860,12 +3875,12 @@ class RequirementsTest(fixtures.MappedTest):
                 H1(
                     "abc",
                     1,
-                    h2s=[H2("abc", id=1), H2("def", id=2), H2("def", id=3)],
+                    h2s=[H2("abc", id_=1), H2("def", id_=2), H2("def", id_=3)],
                 ),
                 H1(
                     "def",
                     2,
-                    h2s=[H2("abc", id=4), H2("abc", id=5), H2("def", id=6)],
+                    h2s=[H2("abc", id_=4), H2("abc", id_=5), H2("def", id_=6)],
                 ),
             ]
         )
index 9ba2e5bf3be5dd11f75df6696662cd7bd4ab58d0..c3e38d1b0de6dcb0660e72bfa42baee7326ceaaa 100644 (file)
@@ -1,32 +1,40 @@
-from sqlalchemy.testing import assert_raises_message
-import sqlalchemy as sa
-from sqlalchemy import Integer, PickleType, String, ForeignKey, Text
 import operator
+
+import sqlalchemy as sa
+from sqlalchemy import and_
+from sqlalchemy import case
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import PickleType
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.util import OrderedSet
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    PropComparator,
-    synonym,
-    comparable_property,
-    sessionmaker,
-    attributes,
-    Session,
-    backref,
-    configure_mappers,
-    foreign,
-    deferred,
-    defer,
-)
+from sqlalchemy import Text
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import comparable_property
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import defer
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import foreign
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import PropComparator
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import synonym
 from sqlalchemy.orm.collections import attribute_mapped_collection
 from sqlalchemy.orm.interfaces import MapperOption
-from sqlalchemy.testing import eq_, in_, not_in_
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import in_
+from sqlalchemy.testing import not_in_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.util import OrderedSet
 from test.orm import _fixtures
-from sqlalchemy import event, and_, case
-from sqlalchemy.testing.schema import Table, Column
 
 
 class MergeTest(_fixtures.FixtureTest):
index 3abc4065e0a1f300aaafbb8087dabf7529db0a3e..52c27f3158141a95a7652fe876700b0934348f02 100644 (file)
@@ -3,18 +3,23 @@ Primary key changing capabilities and passive/non-passive cascading updates.
 
 """
 
-from sqlalchemy.testing import (
-    fixtures,
-    eq_,
-    ne_,
-    assert_raises,
-    assert_raises_message,
-)
 import sqlalchemy as sa
-from sqlalchemy import testing, Integer, String, ForeignKey
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import mapper, relationship, create_session, Session
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
 from sqlalchemy.orm.session import make_transient
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm import _fixtures
 
 
index 0e8757ca85deb175a79d4ed03d291709b415f4f6..6e980e641fb9cc07377e707194c18ec682c954b9 100644 (file)
@@ -1,38 +1,35 @@
-from sqlalchemy.orm import (
-    Session,
-    aliased,
-    with_polymorphic,
-    contains_eager,
-    joinedload,
-    subqueryload,
-    relationship,
-    subqueryload_all,
-    joinedload_all,
-)
 from sqlalchemy import and_
-from sqlalchemy import testing, exc as sa_exc
-from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import assert_raises, assert_raises_message, eq_
-from sqlalchemy.testing.schema import Column
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import testing
 from sqlalchemy.engine import default
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import contains_eager
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import subqueryload_all
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertsql import CompiledSQL
 from sqlalchemy.testing.entities import ComparableEntity
-from sqlalchemy import Integer, String, ForeignKey
-from .inheritance._poly_fixtures import (
-    Company,
-    Person,
-    Engineer,
-    Manager,
-    Boss,
-    Machine,
-    Paperwork,
-    _PolymorphicFixtureBase,
-    _Polymorphic,
-    _PolymorphicPolymorphic,
-    _PolymorphicUnions,
-    _PolymorphicJoins,
-    _PolymorphicAliasedJoins,
-)
-from sqlalchemy.testing.assertsql import AllOf, CompiledSQL
+from sqlalchemy.testing.schema import Column
+from .inheritance._poly_fixtures import _PolymorphicAliasedJoins
+from .inheritance._poly_fixtures import _PolymorphicJoins
+from .inheritance._poly_fixtures import _PolymorphicPolymorphic
+from .inheritance._poly_fixtures import _PolymorphicUnions
+from .inheritance._poly_fixtures import Boss
+from .inheritance._poly_fixtures import Company
+from .inheritance._poly_fixtures import Engineer
+from .inheritance._poly_fixtures import Machine
+from .inheritance._poly_fixtures import Manager
+from .inheritance._poly_fixtures import Person
 
 
 class _PolymorphicTestBase(object):
index 8506592c3540b35b019704f4715f3ea4520275d0..a487c17e6bc7e7c578bbc4c1ba3e8dea36658c66 100644 (file)
@@ -1,9 +1,12 @@
-import sqlalchemy as sa
-from sqlalchemy import testing
-from sqlalchemy import Integer, String, ForeignKey
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import mapper, relationship, create_session
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class O2OTest(fixtures.MappedTest):
index f057890d89f96a19c196a12ec5597b1dd1896279..98b6bccbfd9d7b7603322ea6bd7803615b357349 100644 (file)
@@ -1,34 +1,29 @@
-from sqlalchemy import inspect
-from sqlalchemy.orm import (
-    attributes,
-    mapper,
-    relationship,
-    backref,
-    configure_mappers,
-    create_session,
-    synonym,
-    Session,
-    class_mapper,
-    aliased,
-    column_property,
-    joinedload_all,
-    joinedload,
-    Query,
-    util as orm_util,
-    Load,
-    defer,
-    defaultload,
-    lazyload,
-)
-from sqlalchemy.orm.query import QueryContext
-from sqlalchemy.orm import strategy_options
 import sqlalchemy as sa
+from sqlalchemy import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.assertions import eq_, assert_raises_message
-from test.orm import _fixtures
-from sqlalchemy import Column, Integer, String, ForeignKey
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import defaultload
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import lazyload
+from sqlalchemy.orm import Load
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import strategy_options
 from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import util as orm_util
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertions import assert_raises_message
+from sqlalchemy.testing.assertions import eq_
+from test.orm import _fixtures
 
 
 class QueryTest(_fixtures.FixtureTest):
index 0a3da813e0022e315547aeac6e025e7a22f56a4c..6a368f31cae66bf051bb0013bd67ed084b03da96 100644 (file)
@@ -1,60 +1,49 @@
-from sqlalchemy.testing import eq_
-from sqlalchemy.util import pickle
-import sqlalchemy as sa
 import copy
+
+import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.util import picklers
-from sqlalchemy.testing import assert_raises_message
-from sqlalchemy import Integer, String, ForeignKey, exc, MetaData
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    sessionmaker,
-    attributes,
-    interfaces,
-    clear_mappers,
-    exc as orm_exc,
-    configure_mappers,
-    Session,
-    lazyload_all,
-    lazyload,
-    aliased,
-    subqueryload,
-)
-from sqlalchemy.orm import state as sa_state
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
 from sqlalchemy.orm import instrumentation
-from sqlalchemy.orm.collections import (
-    attribute_mapped_collection,
-    column_mapped_collection,
-)
+from sqlalchemy.orm import lazyload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import state as sa_state
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.orm.collections import attribute_mapped_collection
+from sqlalchemy.orm.collections import column_mapped_collection
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.pickleable import Address
+from sqlalchemy.testing.pickleable import Child1
+from sqlalchemy.testing.pickleable import Child2
+from sqlalchemy.testing.pickleable import Dingaling
+from sqlalchemy.testing.pickleable import EmailUser
+from sqlalchemy.testing.pickleable import Order
+from sqlalchemy.testing.pickleable import Parent
+from sqlalchemy.testing.pickleable import Screen
+from sqlalchemy.testing.pickleable import User
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import picklers
+from sqlalchemy.util import pickle
 from test.orm import _fixtures
-from sqlalchemy.testing.pickleable import (
-    User,
-    Address,
-    Dingaling,
-    Order,
-    Child1,
-    Child2,
-    Parent,
-    Screen,
-    EmailUser,
-)
-
-from sqlalchemy.orm import with_polymorphic
-
-from .inheritance._poly_fixtures import (
-    Company,
-    Person,
-    Engineer,
-    Manager,
-    Boss,
-    Machine,
-    Paperwork,
-    _Polymorphic,
-)
+from .inheritance._poly_fixtures import _Polymorphic
+from .inheritance._poly_fixtures import Company
+from .inheritance._poly_fixtures import Engineer
+from .inheritance._poly_fixtures import Manager
+from .inheritance._poly_fixtures import Person
 
 
 class PickleTest(fixtures.MappedTest):
@@ -704,8 +693,8 @@ class TupleLabelTest(_fixtures.FixtureTest):
         )
         mapper(Address, addresses)
         mapper(
-            Order, orders, properties={"address": relationship(Address)}  # m2o
-        )
+            Order, orders, properties={"address": relationship(Address)}
+        )  # m2o
 
     def test_tuple_labeling(self):
         users = self.tables.users
index 3f975516f5f7239eb1a862955679e033e8c268c1..12f894ef3333989efee48cde988d64476149775e 100644 (file)
@@ -1,68 +1,71 @@
-from sqlalchemy import (
-    testing,
-    null,
-    exists,
-    text,
-    union,
-    literal,
-    literal_column,
-    func,
-    between,
-    Unicode,
-    desc,
-    and_,
-    bindparam,
-    select,
-    distinct,
-    or_,
-    collate,
-    insert,
-    Integer,
-    String,
-    Boolean,
-    exc as sa_exc,
-    util,
-    cast,
-    MetaData,
-    ForeignKey,
-)
-from sqlalchemy.sql import operators, expression
-from sqlalchemy import column, table
+import contextlib
+
+import sqlalchemy as sa
+from sqlalchemy import and_
+from sqlalchemy import between
+from sqlalchemy import bindparam
+from sqlalchemy import Boolean
+from sqlalchemy import cast
+from sqlalchemy import collate
+from sqlalchemy import column
+from sqlalchemy import desc
+from sqlalchemy import distinct
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import exists
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import insert
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import null
+from sqlalchemy import or_
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import table
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import Unicode
+from sqlalchemy import union
+from sqlalchemy import util
 from sqlalchemy.engine import default
-from sqlalchemy.orm import (
-    attributes,
-    mapper,
-    relationship,
-    create_session,
-    synonym,
-    Session,
-    aliased,
-    column_property,
-    joinedload_all,
-    joinedload,
-    Query,
-    Bundle,
-    subqueryload,
-    backref,
-    lazyload,
-    defer,
-)
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import Bundle
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import defer
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import lazyload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Query
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import synonym
+from sqlalchemy.orm.util import join
+from sqlalchemy.orm.util import with_parent
+from sqlalchemy.sql import expression
+from sqlalchemy.sql import operators
+from sqlalchemy.testing import assert_warnings
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import mock
+from sqlalchemy.testing.assertions import assert_raises
+from sqlalchemy.testing.assertions import assert_raises_message
+from sqlalchemy.testing.assertions import eq_
+from sqlalchemy.testing.assertions import eq_ignore_whitespace
+from sqlalchemy.testing.assertions import expect_warnings
 from sqlalchemy.testing.assertsql import CompiledSQL
-from sqlalchemy.testing.schema import Table, Column
-import sqlalchemy as sa
-from sqlalchemy.testing.assertions import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    expect_warnings,
-    eq_ignore_whitespace,
-)
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL, assert_warnings
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm import _fixtures
-from sqlalchemy.orm.util import join, with_parent
-import contextlib
-from sqlalchemy.testing import mock, is_, is_not_
-from sqlalchemy import inspect
 
 
 class QueryTest(_fixtures.FixtureTest):
@@ -1799,7 +1802,8 @@ class ExpressionTest(QueryTest, AssertsCompiledSQL):
         q = session.query(User.id).filter(User.id == 7).label("foo")
         self.assert_compile(
             session.query(q),
-            "SELECT (SELECT users.id FROM users WHERE users.id = :id_1) AS foo",
+            "SELECT (SELECT users.id FROM users "
+            "WHERE users.id = :id_1) AS foo",
         )
 
     def test_as_scalar(self):
@@ -2230,7 +2234,8 @@ class ColumnPropertyTest(_fixtures.FixtureTest, AssertsCompiledSQL):
             "SELECT (SELECT max(addresses.email_address) AS max_1 FROM "
             "addresses WHERE addresses.user_id = users_1.id) AS anon_1, "
             "users_1.id AS users_1_id, users_1.name AS users_1_name, "
-            "users.id AS users_id FROM users AS users_1, users ORDER BY anon_1",
+            "users.id AS users_id FROM users AS users_1, "
+            "users ORDER BY anon_1",
         )
 
     def test_order_by_column_unlabeled_prop_attr_aliased_one(self):
@@ -4776,7 +4781,20 @@ class SynonymTest(QueryTest, AssertsCompiledSQL):
 
     @classmethod
     def setup_mappers(cls):
-        users, Keyword, items, order_items, orders, Item, User, Address, keywords, Order, item_keywords, addresses = (
+        (
+            users,
+            Keyword,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            keywords,
+            Order,
+            item_keywords,
+            addresses,
+        ) = (
             cls.tables.users,
             cls.classes.Keyword,
             cls.tables.items,
@@ -4963,7 +4981,8 @@ class SynonymTest(QueryTest, AssertsCompiledSQL):
         self.assert_compile(
             q,
             "SELECT users_1.name AS users_1_name FROM "
-            "users AS users_1 JOIN addresses ON users_1.id = addresses.user_id",
+            "users AS users_1 JOIN addresses "
+            "ON users_1.id = addresses.user_id",
         )
 
 
index 7aac4cecadc7c00c9ae1ba47ebc7af46679bfbee..8fd521ae8c323de465d9af6000efe08de3e3bf0c 100644 (file)
@@ -1,26 +1,26 @@
-from sqlalchemy.testing import (
-    assert_raises_message,
-    eq_,
-    AssertsCompiledSQL,
-    is_,
-)
+from sqlalchemy import and_
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy.orm import foreign
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import relationships
+from sqlalchemy.orm import remote
+from sqlalchemy.orm.interfaces import MANYTOONE
+from sqlalchemy.orm.interfaces import ONETOMANY
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy.orm import relationships, foreign, remote, relationship
-from sqlalchemy import (
-    MetaData,
-    Table,
-    Column,
-    ForeignKey,
-    Integer,
-    select,
-    ForeignKeyConstraint,
-    exc,
-    func,
-    and_,
-    String,
-    Boolean,
-)
-from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE, MANYTOMANY
+from sqlalchemy.testing import is_
 from sqlalchemy.testing import mock
 
 
@@ -487,22 +487,6 @@ class _JoinFixtures(object):
             **kw
         )
 
-        cls.left = Table(
-            "lft",
-            m,
-            Column("id", Integer, primary_key=True),
-            Column("x", Integer),
-            Column("y", Integer),
-        )
-        cls.right = Table(
-            "rgt",
-            m,
-            Column("id", Integer, primary_key=True),
-            Column("lid", Integer, ForeignKey("lft.id")),
-            Column("x", Integer),
-            Column("y", Integer),
-        )
-
     def _join_fixture_o2m_o_side_none(self, **kw):
         return relationships.JoinCondition(
             self.left,
index 3ca8d8c09906913d58abb6e60c5d0cf7ec8fd859..6e1c699c4103345ada832dd72755cc0dc609e82d 100644 (file)
@@ -1,45 +1,49 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message
 import datetime
+
 import sqlalchemy as sa
-from sqlalchemy import testing
-from sqlalchemy import (
-    Integer,
-    String,
-    ForeignKey,
-    MetaData,
-    and_,
-    select,
-    func,
-)
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    relation,
-    backref,
-    create_session,
-    configure_mappers,
-    clear_mappers,
-    sessionmaker,
-    attributes,
-    Session,
-    composite,
-    column_property,
-    foreign,
-    remote,
-    synonym,
-    joinedload,
-    subqueryload,
-)
-from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE
-from sqlalchemy.testing import eq_, startswith_, AssertsCompiledSQL, is_, in_
-from sqlalchemy.testing import fixtures
-from test.orm import _fixtures
+from sqlalchemy import and_
 from sqlalchemy import exc
-from sqlalchemy.orm import exc as orm_exc
-from sqlalchemy import inspect
+from sqlalchemy import ForeignKey
 from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import func
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import testing
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import composite
+from sqlalchemy.orm import configure_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import foreign
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relation
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import remote
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import synonym
+from sqlalchemy.orm.interfaces import MANYTOONE
+from sqlalchemy.orm.interfaces import ONETOMANY
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import in_
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import startswith_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from test.orm import _fixtures
 
 
 class _RelationshipErrors(object):
@@ -802,15 +806,15 @@ class CompositeSelfRefFKTest(fixtures.MappedTest, AssertsCompiledSQL):
 
     this is a very unusual case::
 
-    company         employee
-    ----------      ----------
-    company_id <--- company_id ------+
-    name                ^            |
-                        +------------+
+        company         employee
+        ----------      ----------
+        company_id <--- company_id ------+
+        name                ^            |
+                            +------------+
 
-                    emp_id <---------+
-                    name             |
-                    reports_to_id ---+
+                        emp_id <---------+
+                        name             |
+                        reports_to_id ---+
 
     employee joins to its sub-employees
     both on reports_to_id, *and on company_id to itself*.
@@ -4134,8 +4138,6 @@ class SecondaryNestedJoinTest(
                     secondary=j,
                     primaryjoin=and_(a.c.b_id == b.c.id, a.c.id == c.c.a_id),
                     secondaryjoin=d.c.id == b.c.d_id,
-                    # primaryjoin=and_(a.c.b_id == j.c.b_id, a.c.id == j.c.c_a_id),
-                    # secondaryjoin=d.c.id == j.c.b_d_id,
                     uselist=False,
                     viewonly=True,
                 ),
index 33abc1496e555927d1762604c810db7caa0f465f..41e5124d41e29986685cf4689cb4dead6fafe3d4 100644 (file)
@@ -1,13 +1,18 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message
 import sqlalchemy as sa
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import query
+from sqlalchemy.orm import relationship
 from sqlalchemy.orm import scoped_session
-from sqlalchemy import Integer, String, ForeignKey
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import mapper, relationship, query
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
 from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class ScopedSessionTest(fixtures.MappedTest):
index 50eaaa37b1e9bb64583eb92cdcd7a59184e06b8d..1fc2f3f16a8868b2db2c650182b87fa7bba8f072 100644 (file)
@@ -1,12 +1,19 @@
 """Generic mapping to Select statements"""
-from sqlalchemy.testing import assert_raises, assert_raises_message
 import sqlalchemy as sa
+from sqlalchemy import column
+from sqlalchemy import Integer
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import String, Integer, select, column
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import mapper, Session
-from sqlalchemy.testing import eq_, AssertsCompiledSQL
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 # TODO: more tests mapping to selects
index 78a56ba319cc368db70ca8bde0c06b2dfbabf7a8..0ace607250fe82ce8fd235838f08595c98361587 100644 (file)
@@ -1,40 +1,42 @@
-from sqlalchemy.testing import eq_, is_, is_not_, is_true
+import sqlalchemy as sa
+from sqlalchemy import bindparam
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy import Integer, String, ForeignKey, bindparam
-from sqlalchemy.orm import (
-    selectinload,
-    selectinload_all,
-    mapper,
-    relationship,
-    clear_mappers,
-    create_session,
-    aliased,
-    joinedload,
-    deferred,
-    undefer,
-    Session,
-    subqueryload,
-    defaultload,
-)
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import defaultload
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import selectinload
+from sqlalchemy.orm import selectinload_all
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import undefer
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_true
 from sqlalchemy.testing import mock
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm import _fixtures
-import sqlalchemy as sa
-
-from sqlalchemy.orm import with_polymorphic
-
-from .inheritance._poly_fixtures import (
-    _Polymorphic,
-    Person,
-    Engineer,
-    Paperwork,
-    Machine,
-    MachineType,
-    Company,
-)
+from .inheritance._poly_fixtures import _Polymorphic
+from .inheritance._poly_fixtures import Company
+from .inheritance._poly_fixtures import Engineer
+from .inheritance._poly_fixtures import Machine
+from .inheritance._poly_fixtures import MachineType
+from .inheritance._poly_fixtures import Paperwork
+from .inheritance._poly_fixtures import Person
 
 
 class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@@ -527,7 +529,18 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         self._do_mapper_test(self._pathing_runs)
 
     def _do_options_test(self, configs):
-        users, Keyword, orders, items, order_items, Order, Item, User, keywords, item_keywords = (
+        (
+            users,
+            Keyword,
+            orders,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            keywords,
+            item_keywords,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.orders,
@@ -587,7 +600,18 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
             self._do_query_tests(options, count)
 
     def _do_mapper_test(self, configs):
-        users, Keyword, orders, items, order_items, Order, Item, User, keywords, item_keywords = (
+        (
+            users,
+            Keyword,
+            orders,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            keywords,
+            item_keywords,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.orders,
@@ -841,7 +865,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         """Eager loading with two relationships simultaneously,
         from the same table, using aliases."""
 
-        addresses, items, order_items, orders, Item, User, Address, Order, users = (
+        (
+            addresses,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            users,
+        ) = (
             self.tables.addresses,
             self.tables.items,
             self.tables.order_items,
@@ -947,7 +981,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
     def test_limit(self):
         """Limit operations combined with lazy-load relationships."""
 
-        users, items, order_items, orders, Item, User, Address, Order, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
index cf908b988a8ffe4bc1c95e22618e6fe6d1ff4350..1f36578df924c0f507c381fa660a1507c220840d 100644 (file)
@@ -1,43 +1,41 @@
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    assertions,
-    is_true,
-    is_,
-)
-from sqlalchemy.testing.util import gc_collect
-from sqlalchemy.testing import pickleable
-from sqlalchemy.util import pickle
-import inspect
-from sqlalchemy.orm import (
-    create_session,
-    sessionmaker,
-    attributes,
-    make_transient,
-    make_transient_to_detached,
-    Session,
-)
 import sqlalchemy as sa
-from sqlalchemy.testing import engines, config
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import Sequence
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy import Integer, String, Sequence
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    backref,
-    joinedload,
-    exc as orm_exc,
-    object_session,
-    was_deleted,
-)
-from sqlalchemy.util import pypy
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import make_transient
+from sqlalchemy.orm import make_transient_to_detached
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import object_session
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import was_deleted
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import assertions
+from sqlalchemy.testing import config
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from test.orm import _fixtures
-from sqlalchemy import event, ForeignKey
-from sqlalchemy.util.compat import inspect_getargspec
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_true
 from sqlalchemy.testing import mock
+from sqlalchemy.testing import pickleable
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import gc_collect
+from sqlalchemy.util import pickle
+from sqlalchemy.util import pypy
+from sqlalchemy.util.compat import inspect_getargspec
+from test.orm import _fixtures
 
 
 class ExecutionTest(_fixtures.FixtureTest):
@@ -1522,12 +1520,12 @@ class StrongIdentityMapTest(_fixtures.FixtureTest):
         # o is still in local scope here, so still present
         self.assert_(len(s.identity_map) == 1)
 
-        id = o.id
+        id_ = o.id
         del o
         eq_(prune(), 1)
         self.assert_(len(s.identity_map) == 0)
 
-        u = s.query(User).get(id)
+        u = s.query(User).get(id_)
         eq_(prune(), 0)
         self.assert_(len(s.identity_map) == 1)
         u.name = "squiznart"
@@ -1546,7 +1544,7 @@ class StrongIdentityMapTest(_fixtures.FixtureTest):
         eq_(prune(), 1)
         self.assert_(len(s.identity_map) == 0)
 
-        u = s.query(User).get(id)
+        u = s.query(User).get(id_)
         s.delete(u)
         del u
         eq_(prune(), 0)
index 8af02520f320c161798d6c2b046556528f7015df..1374d55d8d771bf65b81d3d1004cf59f43e77f9f 100644 (file)
@@ -1,42 +1,42 @@
-from sqlalchemy.testing import eq_, is_, is_not_, is_true
+import sqlalchemy as sa
+from sqlalchemy import bindparam
+from sqlalchemy import ForeignKey
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy import Integer, String, ForeignKey, bindparam, inspect
-from sqlalchemy.orm import (
-    backref,
-    subqueryload,
-    subqueryload_all,
-    mapper,
-    relationship,
-    clear_mappers,
-    create_session,
-    lazyload,
-    aliased,
-    joinedload,
-    deferred,
-    undefer,
-    eagerload_all,
-    Session,
-)
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message
-from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import clear_mappers
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import deferred
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import subqueryload
+from sqlalchemy.orm import subqueryload_all
+from sqlalchemy.orm import undefer
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_true
+from sqlalchemy.testing.assertsql import CompiledSQL
 from sqlalchemy.testing.entities import ComparableEntity
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm import _fixtures
-import sqlalchemy as sa
-
-from sqlalchemy.orm import with_polymorphic
-
-from .inheritance._poly_fixtures import (
-    _Polymorphic,
-    Person,
-    Engineer,
-    Paperwork,
-    Page,
-    Machine,
-    MachineType,
-    Company,
-)
+from .inheritance._poly_fixtures import _Polymorphic
+from .inheritance._poly_fixtures import Company
+from .inheritance._poly_fixtures import Engineer
+from .inheritance._poly_fixtures import Machine
+from .inheritance._poly_fixtures import MachineType
+from .inheritance._poly_fixtures import Page
+from .inheritance._poly_fixtures import Paperwork
+from .inheritance._poly_fixtures import Person
 
 
 class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@@ -529,7 +529,18 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         self._do_mapper_test(self._pathing_runs)
 
     def _do_options_test(self, configs):
-        users, Keyword, orders, items, order_items, Order, Item, User, keywords, item_keywords = (
+        (
+            users,
+            Keyword,
+            orders,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            keywords,
+            item_keywords,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.orders,
@@ -585,7 +596,18 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
             self._do_query_tests(options, count)
 
     def _do_mapper_test(self, configs):
-        users, Keyword, orders, items, order_items, Order, Item, User, keywords, item_keywords = (
+        (
+            users,
+            Keyword,
+            orders,
+            items,
+            order_items,
+            Order,
+            Item,
+            User,
+            keywords,
+            item_keywords,
+        ) = (
             self.tables.users,
             self.classes.Keyword,
             self.tables.orders,
@@ -862,7 +884,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
         """Eager loading with two relationships simultaneously,
         from the same table, using aliases."""
 
-        addresses, items, order_items, orders, Item, User, Address, Order, users = (
+        (
+            addresses,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            users,
+        ) = (
             self.tables.addresses,
             self.tables.items,
             self.tables.order_items,
@@ -968,7 +1000,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
     def test_limit(self):
         """Limit operations combined with lazy-load relationships."""
 
-        users, items, order_items, orders, Item, User, Address, Order, addresses = (
+        (
+            users,
+            items,
+            order_items,
+            orders,
+            Item,
+            User,
+            Address,
+            Order,
+            addresses,
+        ) = (
             self.tables.users,
             self.tables.items,
             self.tables.order_items,
index d1dad43c8b2c29eb41b5b7261f4700177d45bfac..697a8097e5917a44005c31df6cbc59957f9660ab 100644 (file)
@@ -1,21 +1,18 @@
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-from test.orm import _fixtures
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import class_mapper
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import sync
+from sqlalchemy.orm import unitofwork
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
-from sqlalchemy import Integer, String, ForeignKey, func
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    backref,
-    create_session,
-    unitofwork,
-    attributes,
-    Session,
-    class_mapper,
-    sync,
-    exc as orm_exc,
-)
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class AssertsUOW(object):
index 67370aed021cfbc3bf687b0ea7cf7887a831858a..e5708808e753ac9e2f96c68c6fc8da9715326998 100644 (file)
@@ -1,42 +1,37 @@
 from __future__ import with_statement
-from sqlalchemy import (
-    testing,
-    exc as sa_exc,
-    event,
-    String,
-    Column,
-    Table,
-    select,
-    func,
-)
-from sqlalchemy.sql import elements
+
+from sqlalchemy import Column
+from sqlalchemy import event
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import func
+from sqlalchemy import inspect
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import session as _session
+from sqlalchemy.orm import sessionmaker
 from sqlalchemy.orm.util import identity_key
-from sqlalchemy.testing import (
-    fixtures,
-    engines,
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    assert_warnings,
-    mock,
-    expect_warnings,
-    is_,
-    is_not_,
-    is_true,
-)
-from sqlalchemy.orm import (
-    exc as orm_exc,
-    Session,
-    mapper,
-    sessionmaker,
-    create_session,
-    relationship,
-    attributes,
-    session as _session,
-)
+from sqlalchemy.sql import elements
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import assert_warnings
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_true
+from sqlalchemy.testing import mock
 from sqlalchemy.testing.util import gc_collect
 from test.orm._fixtures import FixtureTest
-from sqlalchemy import inspect
 
 
 class SessionTransactionTest(fixtures.RemovesEvents, FixtureTest):
index 4eb6c159997414ef4960f6805cd9683f43b24039..f7a735e21598d47ed952954a4a5056c9b68c9854 100644 (file)
@@ -1,37 +1,37 @@
 # coding: utf-8
 """Tests unitofwork operations."""
 
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message
 import datetime
-from sqlalchemy.util import OrderedDict
 
 import sqlalchemy as sa
-from sqlalchemy.util import u, ue
-from sqlalchemy import (
-    Integer,
-    String,
-    ForeignKey,
-    Enum,
-    literal_column,
-    event,
-    Boolean,
-    select,
-    func,
-)
+from sqlalchemy import Boolean
+from sqlalchemy import Enum
+from sqlalchemy import event
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal_column
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table
-from sqlalchemy.testing.schema import Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    create_session,
-    column_property,
-    Session,
-    exc as orm_exc,
-)
+from sqlalchemy.orm import column_property
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertsql import AllOf
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.util import OrderedDict
+from sqlalchemy.util import u
+from sqlalchemy.util import ue
 from test.orm import _fixtures
-from sqlalchemy.testing.assertsql import AllOf, CompiledSQL
 
 
 class UnitOfWorkTest(object):
@@ -2025,9 +2025,9 @@ class SaveTest(_fixtures.FixtureTest):
         session.flush()
         session.expunge_all()
 
-        id = m.primary_key_from_instance(u)
+        id_ = m.primary_key_from_instance(u)
 
-        u = session.query(User).get(id)
+        u = session.query(User).get(id_)
         assert u.name == "multitester"
 
         user_rows = (
@@ -2053,7 +2053,7 @@ class SaveTest(_fixtures.FixtureTest):
         eq_(list(address_rows[0].values()), [u.id, u.foo_id, "lala@hey.com"])
 
         session.expunge_all()
-        u = session.query(User).get(id)
+        u = session.query(User).get(id_)
         assert u.name == "imnew"
 
     def test_history_get(self):
index f5c39fee73f1cdc3e8102670cc3e26ab93439fca..0a58bb57ae24445b79bb8d213954fd72b7c4f382 100644 (file)
@@ -1,33 +1,35 @@
-from sqlalchemy.testing import eq_, assert_raises_message
+from sqlalchemy import event
+from sqlalchemy import exc
+from sqlalchemy import FetchedValue
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import util
+from sqlalchemy.orm import attributes
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import unitofwork
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import config
 from sqlalchemy.testing import engines
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertsql import AllOf
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.mock import patch
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from test.orm import _fixtures
-from sqlalchemy import exc, util
-from sqlalchemy.testing import fixtures, config
-from sqlalchemy import (
-    Integer,
-    String,
-    ForeignKey,
-    func,
-    literal,
-    FetchedValue,
-    text,
-    select,
-)
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    backref,
-    create_session,
-    unitofwork,
-    attributes,
-    Session,
-    exc as orm_exc,
-)
-from sqlalchemy.testing.mock import Mock, patch
-from sqlalchemy.testing.assertsql import AllOf, CompiledSQL
-from sqlalchemy import event
 
 
 class AssertsUOW(object):
index 1c92091a82987b3d4665d608bbecbc727fb4f026..9e3f8074fc47c9ad372db8f011a0dad6d78dffb5 100644 (file)
@@ -1,31 +1,29 @@
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message, is_
-from sqlalchemy.testing import fixtures
-from sqlalchemy import (
-    Integer,
-    String,
-    ForeignKey,
-    or_,
-    exc,
-    select,
-    func,
-    Boolean,
-    case,
-    text,
-    column,
-)
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    backref,
-    Session,
-    joinedload,
-    synonym,
-    query,
-)
+from sqlalchemy import Boolean
+from sqlalchemy import case
+from sqlalchemy import column
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import or_
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import synonym
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 from sqlalchemy.testing import mock
-
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class UpdateDeleteTest(fixtures.MappedTest):
index d53e99d1319b07cc4979f00773e617c99a3bfc74..fecb9ad91ade0b23f865f391b88a6b117487e7f3 100644 (file)
@@ -1,20 +1,26 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy.orm import util as orm_util
 from sqlalchemy import Column
-from sqlalchemy import util
+from sqlalchemy import inspect
 from sqlalchemy import Integer
 from sqlalchemy import MetaData
 from sqlalchemy import Table
-from sqlalchemy.orm import aliased, with_polymorphic, synonym
-from sqlalchemy.orm import mapper, create_session, Session
+from sqlalchemy import util
+from sqlalchemy.ext.hybrid import hybrid_method
+from sqlalchemy.ext.hybrid import hybrid_property
+from sqlalchemy.orm import aliased
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import synonym
+from sqlalchemy.orm import util as orm_util
+from sqlalchemy.orm import with_polymorphic
+from sqlalchemy.orm.path_registry import PathRegistry
+from sqlalchemy.orm.path_registry import RootRegistry
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
 from test.orm import _fixtures
-from sqlalchemy.testing import eq_, is_
-from sqlalchemy.orm.path_registry import PathRegistry, RootRegistry
-from sqlalchemy import inspect
-from sqlalchemy.ext.hybrid import hybrid_property, hybrid_method
-from sqlalchemy.testing import AssertsCompiledSQL
-
 from .inheritance import _poly_fixtures
 
 
index 923775a7bfc11ef93213cea55a5547003cdab4ee..547815745fd024f36c1ad547080af88f7e1b5f95 100644 (file)
@@ -1,15 +1,17 @@
-from test.orm import _fixtures
-from sqlalchemy.testing import (
-    fixtures,
-    assert_raises,
-    eq_,
-    ne_,
-    assert_raises_message,
-)
-from sqlalchemy.orm import mapper, Session, validates, relationship
-from sqlalchemy.orm import collections
-from sqlalchemy.testing.mock import Mock, call
 from sqlalchemy import exc
+from sqlalchemy.orm import collections
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import validates
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing.mock import call
+from sqlalchemy.testing.mock import Mock
+from test.orm import _fixtures
 
 
 class ValidatorTest(_fixtures.FixtureTest):
index 6b13bdc9d8bdfe8f1eb7564cc59f7b43c2eb0671..e54925f0bd48c5dd447d14b05d212056d4bdd8d8 100644 (file)
@@ -1,36 +1,33 @@
 import datetime
+import uuid
+
 import sqlalchemy as sa
-from sqlalchemy.testing import engines, config
+from sqlalchemy import Date
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import orm
+from sqlalchemy import select
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.mock import patch
-from sqlalchemy import (
-    Integer,
-    String,
-    Date,
-    ForeignKey,
-    orm,
-    exc,
-    select,
-    TypeDecorator,
-)
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.orm import (
-    mapper,
-    relationship,
-    Session,
-    create_session,
-    sessionmaker,
-    exc as orm_exc,
-)
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises,
-    assert_raises_message,
-    fixtures,
-)
-from sqlalchemy.testing.assertsql import CompiledSQL
-import uuid
+from sqlalchemy import TypeDecorator
 from sqlalchemy import util
+from sqlalchemy.orm import create_session
+from sqlalchemy.orm import exc as orm_exc
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import config
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.mock import patch
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 def make_uuid():
@@ -1263,7 +1260,7 @@ class ServerVersioningTest(fixtures.MappedTest):
             pass
 
         @compiles(IncDefault)
-        def compile(element, compiler, **kw):
+        def compile_(element, compiler, **kw):
             # cache the counter value on the statement
             # itself so the assertsql system gets the same
             # value when it compiles the statement a second time
index 29fbbb118bfd977e12353d3ec915543a6f77bf96..e0f3949dea095478eba8afc96e322cad91d59a6c 100644 (file)
@@ -1,18 +1,19 @@
 from __future__ import print_function
 
+import logging
+import random
+import sys
+
 import gevent.monkey
 
-gevent.monkey.patch_all()  # noqa
+from sqlalchemy import create_engine
+from sqlalchemy import event
 
-import logging
+
+gevent.monkey.patch_all()  # noqa
 
 logging.basicConfig()  # noqa
 # logging.getLogger("sqlalchemy.pool").setLevel(logging.INFO)
-from sqlalchemy import event
-import random
-import sys
-from sqlalchemy import create_engine
-import traceback
 
 engine = create_engine(
     "mysql+pymysql://scott:tiger@localhost/test", pool_size=50, max_overflow=0
index fabfe533b4dccb78b87be6148ba1653cc2c0a825..b40d3c8465be79a09b9632d48dbbf4fc66e8fcca 100644 (file)
@@ -1,5 +1,20 @@
+from decimal import Decimal
+import os
+import random
 import warnings
 
+from sqlalchemy import __version__
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import Numeric
+from sqlalchemy import String
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import Session
+
+
 warnings.filterwarnings("ignore", r".*Decimal objects natively")  # noqa
 
 # speed up cdecimal if available
@@ -11,22 +26,6 @@ try:
 except ImportError:
     pass
 
-from sqlalchemy import __version__
-from sqlalchemy import (
-    Column,
-    Integer,
-    create_engine,
-    ForeignKey,
-    String,
-    Numeric,
-)
-
-from sqlalchemy.orm import Session, relationship
-
-from sqlalchemy.ext.declarative import declarative_base
-import random
-import os
-from decimal import Decimal
 
 Base = declarative_base()
 
index cbe4a2be72c727abceed2fc5af5f2e4eed8c0a27..d95a3c58bc6457594c1f3f429da9e319515e25e0 100644 (file)
@@ -3,24 +3,21 @@
 
 """
 
-from sqlalchemy import util
 import sys
-from sqlalchemy.testing.requirements import SuiteRequirements
+
+from sqlalchemy import util
 from sqlalchemy.testing import exclusions
-from sqlalchemy.testing.exclusions import (
-    skip,
-    skip_if,
-    only_if,
-    only_on,
-    fails_on_everything_except,
-    fails_on,
-    fails_if,
-    succeeds_if,
-    SpecPredicate,
-    against,
-    LambdaPredicate,
-    requires_tag,
-)
+from sqlalchemy.testing.exclusions import against
+from sqlalchemy.testing.exclusions import fails_if
+from sqlalchemy.testing.exclusions import fails_on
+from sqlalchemy.testing.exclusions import fails_on_everything_except
+from sqlalchemy.testing.exclusions import LambdaPredicate
+from sqlalchemy.testing.exclusions import only_if
+from sqlalchemy.testing.exclusions import only_on
+from sqlalchemy.testing.exclusions import skip_if
+from sqlalchemy.testing.exclusions import SpecPredicate
+from sqlalchemy.testing.exclusions import succeeds_if
+from sqlalchemy.testing.requirements import SuiteRequirements
 
 
 def no_support(db, reason):
@@ -150,7 +147,8 @@ class DefaultRequirements(SuiteRequirements):
             [
                 LambdaPredicate(
                     lambda config: against(config, "mssql"),
-                    "SQL Server drivers / odbc seem to change their mind on this",
+                    "SQL Server drivers / odbc seem to change "
+                    "their mind on this",
                 ),
                 LambdaPredicate(
                     lambda config: config.db.dialect.supports_native_boolean,
@@ -385,12 +383,13 @@ class DefaultRequirements(SuiteRequirements):
         present in a subquery in the WHERE clause.
 
         This is an ANSI-standard syntax that apparently MySQL can't handle,
-        such as:
+        such as::
+
+            UPDATE documents SET flag=1 WHERE documents.title IN
+                (SELECT max(documents.title) AS title
+                    FROM documents GROUP BY documents.user_id
+                )
 
-        UPDATE documents SET flag=1 WHERE documents.title IN
-            (SELECT max(documents.title) AS title
-                FROM documents GROUP BY documents.user_id
-            )
         """
         return fails_if(
             self._mysql_not_mariadb_103,
@@ -888,7 +887,8 @@ class DefaultRequirements(SuiteRequirements):
                     "sybase+pyodbc",
                     None,
                     None,
-                    "Don't know how do get these values through FreeTDS + Sybase",
+                    "Don't know how do get these values through "
+                    "FreeTDS + Sybase",
                 ),
                 ("firebird", None, None, "Precision must be from 1 to 18"),
             ]
index 181dd79a1f3f5a2151cd19fb161ba6ebb58c3699..7bb612cfa42f4a50714707f4593f53828f44cdf5 100644 (file)
@@ -1,21 +1,23 @@
-from sqlalchemy.testing import assert_raises, eq_, assert_raises_message
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
-from sqlalchemy import (
-    testing,
-    exc,
-    case,
-    select,
-    literal_column,
-    text,
-    and_,
-    Integer,
-    cast,
-    String,
-    Column,
-    Table,
-    MetaData,
-)
-from sqlalchemy.sql import table, column
+from sqlalchemy import and_
+from sqlalchemy import case
+from sqlalchemy import cast
+from sqlalchemy import Column
+from sqlalchemy import exc
+from sqlalchemy import Integer
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy.sql import column
+from sqlalchemy.sql import table
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+
 
 info_table = None
 
index f3305743ade9c42fe6b049264e29e219c807b51e..f152d0ed9dc0c473763f02f1ac52e6ea71b175e4 100644 (file)
@@ -10,76 +10,79 @@ styling and coherent test organization.
 
 """
 
-from sqlalchemy.testing import (
-    eq_,
-    is_,
-    assert_raises,
-    assert_raises_message,
-    eq_ignore_whitespace,
-)
-from sqlalchemy import testing
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
-from sqlalchemy import (
-    Integer,
-    String,
-    MetaData,
-    Table,
-    Column,
-    select,
-    func,
-    not_,
-    cast,
-    text,
-    tuple_,
-    exists,
-    update,
-    bindparam,
-    literal,
-    and_,
-    null,
-    type_coerce,
-    alias,
-    or_,
-    literal_column,
-    Float,
-    TIMESTAMP,
-    Numeric,
-    Date,
-    Text,
-    union,
-    except_,
-    intersect,
-    union_all,
-    Boolean,
-    distinct,
-    join,
-    outerjoin,
-    asc,
-    desc,
-    over,
-    subquery,
-    case,
-    true,
-    CheckConstraint,
-    Sequence,
-)
 import decimal
-from sqlalchemy.util import u
-from sqlalchemy import exc, sql, util, types, schema
-from sqlalchemy.sql import table, column, label
-from sqlalchemy.sql.expression import ClauseList, _literal_as_text, HasPrefixes
+
+from sqlalchemy import alias
+from sqlalchemy import and_
+from sqlalchemy import asc
+from sqlalchemy import bindparam
+from sqlalchemy import Boolean
+from sqlalchemy import case
+from sqlalchemy import cast
+from sqlalchemy import CheckConstraint
+from sqlalchemy import Column
+from sqlalchemy import Date
+from sqlalchemy import desc
+from sqlalchemy import distinct
+from sqlalchemy import exc
+from sqlalchemy import except_
+from sqlalchemy import exists
+from sqlalchemy import Float
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import intersect
+from sqlalchemy import join
+from sqlalchemy import literal
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import not_
+from sqlalchemy import null
+from sqlalchemy import Numeric
+from sqlalchemy import or_
+from sqlalchemy import outerjoin
+from sqlalchemy import over
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import sql
+from sqlalchemy import String
+from sqlalchemy import subquery
+from sqlalchemy import Table
+from sqlalchemy import Text
+from sqlalchemy import text
+from sqlalchemy import TIMESTAMP
+from sqlalchemy import true
+from sqlalchemy import tuple_
+from sqlalchemy import type_coerce
+from sqlalchemy import types
+from sqlalchemy import union
+from sqlalchemy import union_all
+from sqlalchemy import util
+from sqlalchemy.dialects import mysql
+from sqlalchemy.dialects import oracle
+from sqlalchemy.dialects import postgresql
+from sqlalchemy.dialects import sqlite
+from sqlalchemy.dialects import sybase
+from sqlalchemy.dialects.postgresql.base import PGCompiler
+from sqlalchemy.dialects.postgresql.base import PGDialect
 from sqlalchemy.engine import default
-from sqlalchemy.dialects import (
-    mysql,
-    mssql,
-    postgresql,
-    oracle,
-    sqlite,
-    sybase,
-)
-from sqlalchemy.dialects.postgresql.base import PGCompiler, PGDialect
 from sqlalchemy.ext.compiler import compiles
+from sqlalchemy.sql import column
 from sqlalchemy.sql import compiler
+from sqlalchemy.sql import label
+from sqlalchemy.sql import table
+from sqlalchemy.sql.expression import _literal_as_text
+from sqlalchemy.sql.expression import ClauseList
+from sqlalchemy.sql.expression import HasPrefixes
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import eq_ignore_whitespace
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.util import u
+
 
 table1 = table(
     "mytable",
@@ -958,14 +961,14 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
             "zips", column("zipcode"), column("latitude"), column("longitude")
         )
         places = table("places", column("id"), column("nm"))
-        zip = "12345"
+        zipcode = "12345"
         qlat = (
-            select([zips.c.latitude], zips.c.zipcode == zip)
+            select([zips.c.latitude], zips.c.zipcode == zipcode)
             .correlate(None)
             .as_scalar()
         )
         qlng = (
-            select([zips.c.longitude], zips.c.zipcode == zip)
+            select([zips.c.longitude], zips.c.zipcode == zipcode)
             .correlate(None)
             .as_scalar()
         )
@@ -977,7 +980,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
                 zips.c.zipcode,
                 func.latlondist(qlat, qlng).label("dist"),
             ],
-            zips.c.zipcode == zip,
+            zips.c.zipcode == zipcode,
             order_by=["dist", places.c.nm],
         )
 
@@ -3380,7 +3383,7 @@ class DDLTest(fixtures.TestBase, AssertsCompiledSQL):
             pass
 
         @compiles(MyType)
-        def compile(element, compiler, **kw):
+        def compile_(element, compiler, **kw):
             raise exc.CompileError("Couldn't compile type")
 
         return MyType
index a5d2043ce85ce0a123ed0a8d5c3046e5e8d7318d..fdc97315638a5f3a289c1008b2c123f8c6dff0ca 100644 (file)
@@ -1,37 +1,32 @@
-from sqlalchemy.testing import assert_raises, assert_raises_message
-from sqlalchemy import (
-    Table,
-    Integer,
-    String,
-    Column,
-    PrimaryKeyConstraint,
-    ForeignKeyConstraint,
-    ForeignKey,
-    UniqueConstraint,
-    Index,
-    MetaData,
-    CheckConstraint,
-    func,
-    text,
-)
-from sqlalchemy import exc, schema
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsExecutionResults,
-    AssertsCompiledSQL,
-)
+from sqlalchemy import CheckConstraint
+from sqlalchemy import Column
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import func
+from sqlalchemy import Index
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import PrimaryKeyConstraint
+from sqlalchemy import schema
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import UniqueConstraint
 from sqlalchemy.engine import default
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
 from sqlalchemy.testing import engines
-from sqlalchemy.testing.assertions import expect_warnings
 from sqlalchemy.testing import eq_
-from sqlalchemy.testing.assertsql import (
-    AllOf,
-    RegexSQL,
-    CompiledSQL,
-    DialectSQL,
-)
-from sqlalchemy.sql import table, column
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.assertions import expect_warnings
+from sqlalchemy.testing.assertsql import AllOf
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.assertsql import DialectSQL
+from sqlalchemy.testing.assertsql import RegexSQL
 
 
 class ConstraintGenTest(fixtures.TestBase, AssertsExecutionResults):
index 74c32387f4df237a701f839dcc45852da96e2ed5..ed2787b0f1d81db7fc177f97378312b30bbd2608 100644 (file)
@@ -1,20 +1,20 @@
-from sqlalchemy.testing import fixtures, eq_
-from sqlalchemy.testing import AssertsCompiledSQL, assert_raises_message
-from sqlalchemy.sql import (
-    table,
-    column,
-    select,
-    func,
-    literal,
-    exists,
-    and_,
-    bindparam,
-)
 from sqlalchemy.dialects import mssql
 from sqlalchemy.engine import default
 from sqlalchemy.exc import CompileError
+from sqlalchemy.sql import and_
+from sqlalchemy.sql import bindparam
+from sqlalchemy.sql import column
+from sqlalchemy.sql import exists
+from sqlalchemy.sql import func
+from sqlalchemy.sql import literal
+from sqlalchemy.sql import select
+from sqlalchemy.sql import table
 from sqlalchemy.sql.elements import quoted_name
 from sqlalchemy.sql.visitors import cloned_traverse
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
 
 
 class CTETest(fixtures.TestBase, AssertsCompiledSQL):
@@ -245,7 +245,7 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL):
     def test_recursive_union_no_alias_two(self):
         """
 
-        pg's example:
+        pg's example::
 
             WITH RECURSIVE t(n) AS (
                 VALUES (1)
index 6c949f9ee9cec20dfe6100b0a6c755e0878b8005..3cdbfaeccb63294a4d74a2ef1b822df7531b0fce 100644 (file)
@@ -1,7 +1,13 @@
-from sqlalchemy.testing import fixtures
-from sqlalchemy.sql.ddl import SchemaGenerator, SchemaDropper
-from sqlalchemy import MetaData, Table, Column, Integer, Sequence, ForeignKey
+from sqlalchemy import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
 from sqlalchemy import schema
+from sqlalchemy import Sequence
+from sqlalchemy import Table
+from sqlalchemy.sql.ddl import SchemaDropper
+from sqlalchemy.sql.ddl import SchemaGenerator
+from sqlalchemy.testing import fixtures
 from sqlalchemy.testing.mock import Mock
 
 
index b518a606f25126d9df043b00797b2e04d99428de..5ede46ede683c11ce5a8e102fbe398b562b49ee0 100644 (file)
@@ -1,39 +1,45 @@
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises_message,
-    assert_raises,
-    AssertsCompiledSQL,
-    expect_warnings,
-)
 import datetime
-from sqlalchemy.schema import CreateSequence, DropSequence, CreateTable
-from sqlalchemy.sql import select, text, literal_column
+import itertools
+
 import sqlalchemy as sa
+from sqlalchemy import Boolean
+from sqlalchemy import cast
+from sqlalchemy import DateTime
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import MetaData
+from sqlalchemy import Sequence
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import engines
-from sqlalchemy import (
-    MetaData,
-    Integer,
-    String,
-    ForeignKey,
-    Boolean,
-    exc,
-    Sequence,
-    func,
-    literal,
-    Unicode,
-    cast,
-    DateTime,
-)
-from sqlalchemy.types import TypeDecorator, TypeEngine
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy import Unicode
+from sqlalchemy import util
 from sqlalchemy.dialects import sqlite
+from sqlalchemy.schema import CreateSequence
+from sqlalchemy.schema import CreateTable
+from sqlalchemy.schema import DropSequence
+from sqlalchemy.sql import literal_column
+from sqlalchemy.sql import select
+from sqlalchemy.sql import text
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
 from sqlalchemy.testing import fixtures
-from sqlalchemy.util import u, b
-from sqlalchemy import util
 from sqlalchemy.testing import mock
-import itertools
-from sqlalchemy.testing.assertsql import CompiledSQL, AllOf, EachOf
+from sqlalchemy.testing.assertsql import AllOf
+from sqlalchemy.testing.assertsql import CompiledSQL
+from sqlalchemy.testing.assertsql import EachOf
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.types import TypeDecorator
+from sqlalchemy.types import TypeEngine
+from sqlalchemy.util import b
+from sqlalchemy.util import u
+
 
 t = f = f2 = ts = currenttime = metadata = default_generator = None
 
index cb5e696f20a74f339c1ec95ebe61cc1d08b78c4c..f572a510ca5a625063a9180a51b65eddd55eeb34 100644 (file)
@@ -1,26 +1,23 @@
 #! coding:utf-8
 
-from sqlalchemy import (
-    Integer,
-    String,
-    ForeignKey,
-    delete,
-    select,
-    and_,
-    or_,
-    exists,
-)
+from sqlalchemy import and_
+from sqlalchemy import delete
+from sqlalchemy import exc
+from sqlalchemy import exists
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import or_
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import testing
 from sqlalchemy.dialects import mysql
 from sqlalchemy.engine import default
-from sqlalchemy import testing
-from sqlalchemy import exc
-from sqlalchemy.testing import (
-    AssertsCompiledSQL,
-    fixtures,
-    eq_,
-    assert_raises_message,
-)
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class _DeleteTestBase(object):
index b775df7406445ec17f9e6981a0d6abc1f2d0927a..83277ae9868d4861ab9cad3ca468a23c457579bb 100644 (file)
@@ -1,36 +1,46 @@
-from sqlalchemy.testing import eq_, is_
 import datetime
-from sqlalchemy import (
-    func,
-    select,
-    Integer,
-    literal,
-    DateTime,
-    Table,
-    Column,
-    Sequence,
-    MetaData,
-    extract,
-    Date,
-    String,
-    bindparam,
-    literal_column,
-    ARRAY,
-    Numeric,
-    Boolean,
-)
-from sqlalchemy.sql import table, column
-from sqlalchemy import sql, util
-from sqlalchemy.sql.compiler import BIND_TEMPLATES
-from sqlalchemy.testing.engines import all_dialects
-from sqlalchemy import types as sqltypes
-from sqlalchemy.sql import functions
-from sqlalchemy.sql.functions import GenericFunction, FunctionElement
 import decimal
+
+from sqlalchemy import ARRAY
+from sqlalchemy import bindparam
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import Date
+from sqlalchemy import DateTime
+from sqlalchemy import extract
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import Numeric
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import sql
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL, engines
-from sqlalchemy.dialects import sqlite, postgresql, mysql, oracle
-from sqlalchemy.testing import assert_raises_message, assert_raises
+from sqlalchemy import types as sqltypes
+from sqlalchemy import util
+from sqlalchemy.dialects import mysql
+from sqlalchemy.dialects import oracle
+from sqlalchemy.dialects import postgresql
+from sqlalchemy.dialects import sqlite
+from sqlalchemy.sql import column
+from sqlalchemy.sql import functions
+from sqlalchemy.sql import table
+from sqlalchemy.sql.compiler import BIND_TEMPLATES
+from sqlalchemy.sql.functions import FunctionElement
+from sqlalchemy.sql.functions import GenericFunction
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.engines import all_dialects
+
 
 table1 = table(
     "mytable",
@@ -795,7 +805,7 @@ class ExecuteTest(fixtures.TestBase):
             type = Date()
 
         @compiles(myfunc)
-        def compile(elem, compiler, **kw):
+        def compile_(elem, compiler, **kw):
             return compiler.process(func.current_date())
 
         conn = testing.db.connect()
@@ -861,8 +871,8 @@ class ExecuteTest(fixtures.TestBase):
         assert t.select().execute().first()["value"] == 5
 
         r = t.insert(values=dict(value=func.length("sfsaafsda"))).execute()
-        id = r.inserted_primary_key[0]
-        assert t.select(t.c.id == id).execute().first()["value"] == 9
+        id_ = r.inserted_primary_key[0]
+        assert t.select(t.c.id == id_).execute().first()["value"] == 9
         t.update(values={t.c.value: func.length("asdf")}).execute()
         assert t.select().execute().first()["value"] == 4
         t2.insert().execute()
@@ -897,6 +907,7 @@ class ExecuteTest(fixtures.TestBase):
         t2.update(
             values={t2.c.value: func.length("asfdaasdf"), t2.c.stuff: "foo"}
         ).execute()
+
         eq_(select([t2.c.value, t2.c.stuff]).execute().first(), (9, "foo"))
 
     @testing.fails_on_everything_except("postgresql")
index 1d064dd3a1f76f962591b27450a66aa3caf08a38..1e6221cdcafd3d5be04689b94decba8d5c6fa781 100644 (file)
@@ -1,45 +1,42 @@
-from sqlalchemy.sql import table, column, ClauseElement, operators
-from sqlalchemy.sql.expression import _clone, _from_objects
-from sqlalchemy import (
-    func,
-    select,
-    Integer,
-    Table,
-    Column,
-    MetaData,
-    extract,
-    String,
-    bindparam,
-    tuple_,
-    and_,
-    union,
-    text,
-    case,
-    ForeignKey,
-    literal_column,
-)
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsExecutionResults,
-    AssertsCompiledSQL,
-)
-from sqlalchemy import testing
-from sqlalchemy.sql.visitors import (
-    ClauseVisitor,
-    CloningVisitor,
-    cloned_traverse,
-    ReplacingCloningVisitor,
-)
-from sqlalchemy.sql import visitors
+from sqlalchemy import and_
+from sqlalchemy import bindparam
+from sqlalchemy import case
+from sqlalchemy import Column
 from sqlalchemy import exc
+from sqlalchemy import extract
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import tuple_
+from sqlalchemy import union
+from sqlalchemy.sql import ClauseElement
+from sqlalchemy.sql import column
+from sqlalchemy.sql import operators
+from sqlalchemy.sql import table
 from sqlalchemy.sql import util as sql_util
-from sqlalchemy.testing import (
-    eq_,
-    is_,
-    is_not_,
-    assert_raises,
-    assert_raises_message,
-)
+from sqlalchemy.sql import visitors
+from sqlalchemy.sql.expression import _clone
+from sqlalchemy.sql.expression import _from_objects
+from sqlalchemy.sql.visitors import ClauseVisitor
+from sqlalchemy.sql.visitors import cloned_traverse
+from sqlalchemy.sql.visitors import CloningVisitor
+from sqlalchemy.sql.visitors import ReplacingCloningVisitor
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+
 
 A = B = t1 = t2 = t3 = table1 = table2 = table3 = table4 = None
 
@@ -230,9 +227,9 @@ class TraversalTest(fixtures.TestBase, AssertsExecutionResults):
         assert CustomObj.__visit_name__ == Column.__visit_name__ == "column"
 
         foo, bar = CustomObj("foo", String), CustomObj("bar", String)
-        bin = foo == bar
-        set(ClauseVisitor().iterate(bin))
-        assert set(ClauseVisitor().iterate(bin)) == set([foo, bar, bin])
+        bin_ = foo == bar
+        set(ClauseVisitor().iterate(bin_))
+        assert set(ClauseVisitor().iterate(bin_)) == set([foo, bar, bin_])
 
 
 class BinaryEndpointTraversalTest(fixtures.TestBase):
index 3643deabdfb971017b240c150772ea44bdee91ff..066e54e93c8a3f6303709ed68ff565d2bd838461 100644 (file)
@@ -1,32 +1,29 @@
 #! coding:utf-8
 
-from sqlalchemy import (
-    Column,
-    Integer,
-    MetaData,
-    String,
-    Table,
-    bindparam,
-    exc,
-    func,
-    insert,
-    select,
-    column,
-    text,
-    table,
-    Sequence,
-)
-from sqlalchemy.dialects import mysql, postgresql
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import column
+from sqlalchemy import exc
+from sqlalchemy import func
+from sqlalchemy import insert
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import table
+from sqlalchemy import text
+from sqlalchemy.dialects import mysql
+from sqlalchemy.dialects import postgresql
 from sqlalchemy.engine import default
-from sqlalchemy.testing import (
-    AssertsCompiledSQL,
-    assert_raises_message,
-    fixtures,
-    eq_,
-    expect_warnings,
-    assert_raises,
-)
 from sqlalchemy.sql import crud
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
 
 
 class _InsertTestBase(object):
index 7803de75e7eb1421557da7f6d7bcbc34ae332012..fafe7cc9ba97d7304c15423db76d0bfaf074235d 100644 (file)
@@ -1,20 +1,22 @@
-from sqlalchemy.testing import eq_, assert_raises_message, is_
+from sqlalchemy import and_
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import INT
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Sequence
+from sqlalchemy import sql
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import fixtures, engines
-from sqlalchemy import (
-    exc,
-    sql,
-    String,
-    Integer,
-    MetaData,
-    and_,
-    ForeignKey,
-    VARCHAR,
-    INT,
-    Sequence,
-    func,
-)
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy import VARCHAR
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class InsertExecTest(fixtures.TablesTest):
@@ -94,16 +96,16 @@ class InsertExecTest(fixtures.TablesTest):
             result = engine.execute(table_.insert(), **values)
             ret = values.copy()
 
-            for col, id in zip(
+            for col, id_ in zip(
                 table_.primary_key, result.inserted_primary_key
             ):
-                ret[col.key] = id
+                ret[col.key] = id_
 
             if result.lastrow_has_defaults():
                 criterion = and_(
                     *[
-                        col == id
-                        for col, id in zip(
+                        col == id_
+                        for col, id_ in zip(
                             table_.primary_key, result.inserted_primary_key
                         )
                     ]
index 0e78c06c81da39bedf7c5fae4b12e7f84fad8e78..0b7aa7a555289599828c62bb087c36ce4fee0aa9 100644 (file)
@@ -1,7 +1,10 @@
 """test the inspection registry system."""
 
+from sqlalchemy import Column
 from sqlalchemy import inspect
-from sqlalchemy import Table, Column, Integer, MetaData
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Table
 from sqlalchemy.testing import fixtures
 from sqlalchemy.testing import is_
 
index dd74406fd77575fabd6d5659ffc2713d0227227c..59bbc110476f1924c3661d71b83f528a3fba3c15 100644 (file)
@@ -3,20 +3,19 @@ to support SQLite's lack of right-nested joins.  SQlite as of
 version 3.7.16 no longer has this limitation.
 
 """
-from sqlalchemy import (
-    Table,
-    Column,
-    Integer,
-    MetaData,
-    ForeignKey,
-    select,
-    exists,
-    union,
-)
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
+from sqlalchemy import Column
+from sqlalchemy import exists
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import union
 from sqlalchemy import util
 from sqlalchemy.engine import default
-from sqlalchemy import testing
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import fixtures
 
 
 m = MetaData()
index 8dfaa68599c87b159755e0285e73897827b26c13..901f941bea39dd54063f5631b3c7ce631c0e6d8a 100644 (file)
@@ -1,22 +1,21 @@
-from sqlalchemy import (
-    exc as exceptions,
-    select,
-    MetaData,
-    Integer,
-    or_,
-    bindparam,
-)
+from sqlalchemy import bindparam
+from sqlalchemy import exc as exceptions
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import or_
+from sqlalchemy import select
 from sqlalchemy.engine import default
-from sqlalchemy.sql import table, column
+from sqlalchemy.sql import column
+from sqlalchemy.sql import table
 from sqlalchemy.sql.elements import _truncated_label
-from sqlalchemy.testing import (
-    AssertsCompiledSQL,
-    assert_raises,
-    engines,
-    fixtures,
-    eq_,
-)
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+
 
 IDENT_LENGTH = 29
 
index 163f636f6ff2500eef089e69f7358c643d26d0d1..ee43475c84d622581fa39e739bce6b6f9c7fcbc1 100644 (file)
@@ -1,10 +1,16 @@
-from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import AssertsCompiledSQL, assert_raises_message
-from sqlalchemy.sql import select, func
+from sqlalchemy import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import join
+from sqlalchemy import lateral
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import true
 from sqlalchemy.engine import default
-from sqlalchemy import exc
-from sqlalchemy import Table, Integer, String, ForeignKey, Column, true
-from sqlalchemy import lateral, outerjoin, join
+from sqlalchemy.sql import func
+from sqlalchemy.sql import select
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import fixtures
 
 
 class LateralTest(fixtures.TablesTest, AssertsCompiledSQL):
index 9a28b0c7b7149fd02fcc39487ff7c3e234447521..a6d4b2d1a3f4f82890176d4dceb57ee614c06dae 100644 (file)
@@ -1,45 +1,49 @@
-from sqlalchemy.testing import assert_raises
-from sqlalchemy.testing import assert_raises_message
-from sqlalchemy.testing import emits_warning
+from contextlib import contextmanager
 import pickle
-from sqlalchemy import (
-    Integer,
-    String,
-    UniqueConstraint,
-    CheckConstraint,
-    ForeignKey,
-    MetaData,
-    Sequence,
-    ForeignKeyConstraint,
-    PrimaryKeyConstraint,
-    ColumnDefault,
-    Index,
-    event,
-    events,
-    Unicode,
-    types as sqltypes,
-    bindparam,
-    Table,
-    Column,
-    Boolean,
-    Enum,
-    func,
-    text,
-    TypeDecorator,
-    BLANK_SCHEMA,
-    ARRAY,
-)
-from sqlalchemy import schema, exc
-from sqlalchemy.engine import default
-from sqlalchemy.sql import elements, naming
+
 import sqlalchemy as tsa
-from sqlalchemy.testing import fixtures
+from sqlalchemy import ARRAY
+from sqlalchemy import bindparam
+from sqlalchemy import BLANK_SCHEMA
+from sqlalchemy import Boolean
+from sqlalchemy import CheckConstraint
+from sqlalchemy import Column
+from sqlalchemy import ColumnDefault
+from sqlalchemy import Enum
+from sqlalchemy import event
+from sqlalchemy import exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import func
+from sqlalchemy import Index
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import PrimaryKeyConstraint
+from sqlalchemy import schema
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.testing import ComparesTables, AssertsCompiledSQL
-from sqlalchemy.testing import eq_, is_, mock, is_true, is_false
-from contextlib import contextmanager
+from sqlalchemy import text
+from sqlalchemy import TypeDecorator
+from sqlalchemy import types as sqltypes
+from sqlalchemy import Unicode
+from sqlalchemy import UniqueConstraint
 from sqlalchemy import util
-from sqlalchemy.testing import engines
+from sqlalchemy.engine import default
+from sqlalchemy.sql import elements
+from sqlalchemy.sql import naming
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import ComparesTables
+from sqlalchemy.testing import emits_warning
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_false
+from sqlalchemy.testing import is_true
+from sqlalchemy.testing import mock
 
 
 class MetaDataTest(fixtures.TestBase, ComparesTables):
@@ -526,7 +530,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables):
             (
                 name,
                 metadata,
-                schema,
+                schema_,
                 quote_schema,
                 exp_schema,
                 exp_quote_schema,
@@ -554,8 +558,8 @@ class MetaDataTest(fixtures.TestBase, ComparesTables):
             ]
         ):
             kw = {}
-            if schema is not None:
-                kw["schema"] = schema
+            if schema_ is not None:
+                kw["schema"] = schema_
             if quote_schema is not None:
                 kw["quote_schema"] = quote_schema
             t = Table(name, metadata, **kw)
@@ -3512,12 +3516,12 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase):
         from sqlalchemy.sql import select
 
         class MyColumn(Column):
-            def _constructor(self, name, type, **kw):
+            def _constructor(self, name, type_, **kw):
                 kw["name"] = name
-                return MyColumn(type, **kw)
+                return MyColumn(type_, **kw)
 
-            def __init__(self, type, **kw):
-                Column.__init__(self, type, **kw)
+            def __init__(self, type_, **kw):
+                Column.__init__(self, type_, **kw)
 
             def my_goofy_thing(self):
                 return "hi"
@@ -3527,11 +3531,11 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase):
             s = compiler.visit_column(element, **kw)
             return s + "-"
 
-        id = MyColumn(Integer, primary_key=True)
-        id.name = "id"
+        id_ = MyColumn(Integer, primary_key=True)
+        id_.name = "id"
         name = MyColumn(String)
         name.name = "name"
-        t1 = Table("foo", MetaData(), id, name)
+        t1 = Table("foo", MetaData(), id_, name)
 
         # goofy thing
         eq_(t1.c.name.my_goofy_thing(), "hi")
@@ -3555,14 +3559,14 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase):
         from sqlalchemy.sql import select
 
         class MyColumn(Column):
-            def __init__(self, type, **kw):
-                Column.__init__(self, type, **kw)
+            def __init__(self, type_, **kw):
+                Column.__init__(self, type_, **kw)
 
-        id = MyColumn(Integer, primary_key=True)
-        id.name = "id"
+        id_ = MyColumn(Integer, primary_key=True)
+        id_.name = "id"
         name = MyColumn(String)
         name.name = "name"
-        t1 = Table("foo", MetaData(), id, name)
+        t1 = Table("foo", MetaData(), id_, name)
         assert_raises_message(
             TypeError,
             "Could not create a copy of this <class "
@@ -3577,7 +3581,7 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase):
         from sqlalchemy.ext.compiler import compiles, deregister
 
         @compiles(schema.CreateColumn)
-        def compile(element, compiler, **kw):
+        def compile_(element, compiler, **kw):
             column = element.element
 
             if "special" not in column.info:
index 2ce842cafc25ca7b667860b91a5f854743fc0650..978d3101d651a723330574433afa4c9de151bf65 100644 (file)
@@ -1,63 +1,68 @@
-from sqlalchemy.testing import fixtures, eq_, is_, is_not_
-from sqlalchemy import testing
-from sqlalchemy.testing import assert_raises_message
-from sqlalchemy.testing import expect_warnings
-from sqlalchemy.sql import (
-    column,
-    desc,
-    asc,
-    literal,
-    collate,
-    null,
-    true,
-    false,
-    any_,
-    all_,
-)
-from sqlalchemy.sql import sqltypes
-from sqlalchemy.sql.expression import (
-    BinaryExpression,
-    ClauseList,
-    Grouping,
-    UnaryExpression,
-    select,
-    union,
-    func,
-    tuple_,
-)
-from sqlalchemy.sql import operators, table
+import datetime
 import operator
-from sqlalchemy import String, Integer, LargeBinary
+
+from sqlalchemy import and_
+from sqlalchemy import between
 from sqlalchemy import exc
+from sqlalchemy import Integer
+from sqlalchemy import LargeBinary
+from sqlalchemy import literal_column
+from sqlalchemy import not_
+from sqlalchemy import or_
+from sqlalchemy import String
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import util
+from sqlalchemy.dialects import firebird
+from sqlalchemy.dialects import mssql
+from sqlalchemy.dialects import mysql
+from sqlalchemy.dialects import oracle
+from sqlalchemy.dialects import postgresql
+from sqlalchemy.dialects import sqlite
 from sqlalchemy.engine import default
-from sqlalchemy.sql.elements import _literal_as_text, Label
-from sqlalchemy.schema import Column, Table, MetaData
+from sqlalchemy.schema import Column
+from sqlalchemy.schema import MetaData
+from sqlalchemy.schema import Table
+from sqlalchemy.sql import all_
+from sqlalchemy.sql import any_
+from sqlalchemy.sql import asc
+from sqlalchemy.sql import collate
+from sqlalchemy.sql import column
 from sqlalchemy.sql import compiler
-from sqlalchemy.types import (
-    TypeEngine,
-    TypeDecorator,
-    UserDefinedType,
-    Boolean,
-    MatchType,
-    Indexable,
-    Concatenable,
-    ARRAY,
-    JSON,
-    DateTime,
-)
-from sqlalchemy.dialects import (
-    mysql,
-    firebird,
-    postgresql,
-    oracle,
-    sqlite,
-    mssql,
-)
-from sqlalchemy import util
-import datetime
-import collections
-from sqlalchemy import text, literal_column
-from sqlalchemy import and_, not_, between, or_
+from sqlalchemy.sql import desc
+from sqlalchemy.sql import false
+from sqlalchemy.sql import literal
+from sqlalchemy.sql import null
+from sqlalchemy.sql import operators
+from sqlalchemy.sql import sqltypes
+from sqlalchemy.sql import table
+from sqlalchemy.sql import true
+from sqlalchemy.sql.elements import _literal_as_text
+from sqlalchemy.sql.elements import Label
+from sqlalchemy.sql.expression import BinaryExpression
+from sqlalchemy.sql.expression import ClauseList
+from sqlalchemy.sql.expression import func
+from sqlalchemy.sql.expression import Grouping
+from sqlalchemy.sql.expression import select
+from sqlalchemy.sql.expression import tuple_
+from sqlalchemy.sql.expression import UnaryExpression
+from sqlalchemy.sql.expression import union
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
+from sqlalchemy.types import ARRAY
+from sqlalchemy.types import Boolean
+from sqlalchemy.types import Concatenable
+from sqlalchemy.types import DateTime
+from sqlalchemy.types import Indexable
+from sqlalchemy.types import JSON
+from sqlalchemy.types import MatchType
+from sqlalchemy.types import TypeDecorator
+from sqlalchemy.types import TypeEngine
+from sqlalchemy.types import UserDefinedType
 
 
 class LoopOperate(operators.ColumnOperators):
@@ -604,10 +609,10 @@ class ExtensionOperatorTest(fixtures.TestBase, testing.AssertsCompiledSQL):
 class JSONIndexOpTest(fixtures.TestBase, testing.AssertsCompiledSQL):
     def setUp(self):
         class MyTypeCompiler(compiler.GenericTypeCompiler):
-            def visit_mytype(self, type, **kw):
+            def visit_mytype(self, type_, **kw):
                 return "MYTYPE"
 
-            def visit_myothertype(self, type, **kw):
+            def visit_myothertype(self, type_, **kw):
                 return "MYOTHERTYPE"
 
         class MyCompiler(compiler.SQLCompiler):
@@ -721,10 +726,10 @@ class JSONIndexOpTest(fixtures.TestBase, testing.AssertsCompiledSQL):
 class ArrayIndexOpTest(fixtures.TestBase, testing.AssertsCompiledSQL):
     def setUp(self):
         class MyTypeCompiler(compiler.GenericTypeCompiler):
-            def visit_mytype(self, type, **kw):
+            def visit_mytype(self, type_, **kw):
                 return "MYTYPE"
 
-            def visit_myothertype(self, type, **kw):
+            def visit_myothertype(self, type_, **kw):
                 return "MYOTHERTYPE"
 
         class MyCompiler(compiler.SQLCompiler):
index 13f3b01ff2ceb4606a3e4d0ca40ba55fc32e5e64..2726b3f3c20d14c7847071fa417a6cea4106c4c4 100644 (file)
@@ -1,43 +1,39 @@
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises_message,
-    assert_raises,
-    is_,
-    in_,
-    not_in_,
-)
+from sqlalchemy import and_
+from sqlalchemy import asc
+from sqlalchemy import bindparam
+from sqlalchemy import cast
+from sqlalchemy import desc
+from sqlalchemy import exc
+from sqlalchemy import except_
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import INT
+from sqlalchemy import Integer
+from sqlalchemy import intersect
+from sqlalchemy import literal
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import not_
+from sqlalchemy import or_
+from sqlalchemy import select
+from sqlalchemy import sql
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import fixtures, engines
-from sqlalchemy import (
-    exc,
-    sql,
-    func,
-    select,
-    String,
-    Integer,
-    MetaData,
-    and_,
-    ForeignKey,
-    union,
-    intersect,
-    except_,
-    union_all,
-    VARCHAR,
-    INT,
-    text,
-    bindparam,
-    literal,
-    not_,
-    literal_column,
-    desc,
-    asc,
-    TypeDecorator,
-    or_,
-    cast,
-    tuple_,
-)
+from sqlalchemy import text
+from sqlalchemy import tuple_
+from sqlalchemy import TypeDecorator
+from sqlalchemy import union
+from sqlalchemy import union_all
+from sqlalchemy import VARCHAR
 from sqlalchemy.engine import default
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+
 
 # ongoing - these are old tests.  those which are of general use
 # to test a dialect are being slowly migrated to
index 4cc185298ebbaa062c29ba58ac49d0c150503911..49dfbba9f3df96a426e0234b0767751fe3c67115 100644 (file)
@@ -1,22 +1,24 @@
-from sqlalchemy import (
-    MetaData,
-    Table,
-    Column,
-    Integer,
-    select,
-    ForeignKey,
-    Index,
-    CheckConstraint,
-    inspect,
-    column,
-)
-from sqlalchemy import sql, schema, types as sqltypes
-from sqlalchemy.sql import compiler
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL, eq_
+from sqlalchemy import CheckConstraint
+from sqlalchemy import Column
+from sqlalchemy import column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Index
+from sqlalchemy import inspect
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import schema
+from sqlalchemy import select
+from sqlalchemy import sql
+from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.sql.elements import quoted_name, _anonymous_label
-from sqlalchemy.testing.util import picklers
 from sqlalchemy.engine import default
+from sqlalchemy.sql import compiler
+from sqlalchemy.sql.elements import _anonymous_label
+from sqlalchemy.sql.elements import quoted_name
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.util import picklers
 
 
 class QuoteExecTest(fixtures.TestBase):
@@ -215,18 +217,18 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
         """test the quoting of labels.
 
         If labels aren't quoted, a query in postgresql in particular will
-        fail since it produces:
-
-        SELECT
-            LaLa.lowercase, LaLa."UPPERCASE", LaLa."MixedCase", LaLa."ASC"
-        FROM (
-            SELECT DISTINCT
-                "WorstCase1".lowercase AS lowercase,
-                "WorstCase1"."UPPERCASE" AS UPPERCASE,
-                "WorstCase1"."MixedCase" AS MixedCase,
-                "WorstCase1"."ASC" AS ASC
-            FROM "WorstCase1"
-        ) AS LaLa
+        fail since it produces::
+
+            SELECT
+                LaLa.lowercase, LaLa."UPPERCASE", LaLa."MixedCase", LaLa."ASC"
+            FROM (
+                SELECT DISTINCT
+                    "WorstCase1".lowercase AS lowercase,
+                    "WorstCase1"."UPPERCASE" AS UPPERCASE,
+                    "WorstCase1"."MixedCase" AS MixedCase,
+                    "WorstCase1"."ASC" AS ASC
+                FROM "WorstCase1"
+            ) AS LaLa
 
         where the "UPPERCASE" column of "LaLa" doesn't exist.
         """
index c5e1efef602016bb186062f07ec65405f6987258..3bd61b1f83daa92ecc8e260b987293b7709e345c 100644 (file)
@@ -1,44 +1,44 @@
-from sqlalchemy.testing import (
-    eq_,
-    assert_raises_message,
-    assert_raises,
-    in_,
-    not_in_,
-    is_,
-    ne_,
-    le_,
-)
+from contextlib import contextmanager
+import operator
+
+from sqlalchemy import CHAR
+from sqlalchemy import column
+from sqlalchemy import exc
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import INT
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import sql
+from sqlalchemy import String
+from sqlalchemy import table
 from sqlalchemy import testing
-from sqlalchemy.testing import fixtures, engines
+from sqlalchemy import text
+from sqlalchemy import type_coerce
+from sqlalchemy import TypeDecorator
 from sqlalchemy import util
-from sqlalchemy import (
-    exc,
-    sql,
-    func,
-    select,
-    String,
-    Integer,
-    MetaData,
-    ForeignKey,
-    VARCHAR,
-    INT,
-    CHAR,
-    text,
-    type_coerce,
-    literal_column,
-    TypeDecorator,
-    table,
-    column,
-    literal,
-)
+from sqlalchemy import VARCHAR
+from sqlalchemy.engine import default
 from sqlalchemy.engine import result as _result
-from sqlalchemy.testing.schema import Table, Column
-import operator
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import assertions
-from sqlalchemy import exc as sa_exc
-from sqlalchemy.testing.mock import patch, Mock
-from contextlib import contextmanager
-from sqlalchemy.engine import default
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import in_
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import le_
+from sqlalchemy.testing import ne_
+from sqlalchemy.testing import not_in_
+from sqlalchemy.testing.mock import Mock
+from sqlalchemy.testing.mock import patch
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class ResultProxyTest(fixtures.TablesTest):
index e298a2d552407fb16e0a51c3e538ed904c1174f8..aa10626c5c853aea3d634f3d5d39ef9666f31fe5 100644 (file)
@@ -1,24 +1,23 @@
-from sqlalchemy.testing import eq_
+import itertools
+
+from sqlalchemy import Boolean
+from sqlalchemy import exc as sa_exc
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 from sqlalchemy.types import TypeDecorator
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsExecutionResults,
-    engines,
-    assert_raises_message,
-)
-from sqlalchemy import exc as sa_exc
-from sqlalchemy import (
-    MetaData,
-    String,
-    Integer,
-    Boolean,
-    func,
-    select,
-    Sequence,
-)
-import itertools
+
 
 table = GoofyType = seq = None
 
@@ -313,7 +312,7 @@ class ReturnDefaultsTest(fixtures.TablesTest):
             pass
 
         @compiles(IncDefault)
-        def compile(element, compiler, **kw):
+        def compile_(element, compiler, **kw):
             return str(next(counter))
 
         Table(
index 126e1f0cd87409936c8c85a33094ef2e3a26a3d0..8cff8c98f75e413aae8f2f3d20c68256b61195dc 100644 (file)
@@ -1,7 +1,15 @@
-from sqlalchemy import *
-from sqlalchemy.testing import fixtures, AssertsExecutionResults
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy.testing import AssertsExecutionResults
 from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
 
 
 class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults):
index 023a0bc61b5b8760bedf82051d23e8ceb41af2ce..5456dfb4f2633631475d302febd990c5fc737f08 100644 (file)
@@ -1,19 +1,47 @@
 """Test various algorithmic properties of selectables."""
 
-from sqlalchemy.testing import eq_, assert_raises, assert_raises_message, is_
-from sqlalchemy import *
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsCompiledSQL,
-    AssertsExecutionResults,
-)
-from sqlalchemy.sql import elements
-from sqlalchemy import testing
-from sqlalchemy.sql import util as sql_util, visitors, expression
+from sqlalchemy import alias
+from sqlalchemy import and_
+from sqlalchemy import bindparam
+from sqlalchemy import Boolean
+from sqlalchemy import cast
+from sqlalchemy import Column
 from sqlalchemy import exc
-from sqlalchemy.sql import table, column, null
+from sqlalchemy import exists
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import join
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import not_
+from sqlalchemy import null
+from sqlalchemy import or_
+from sqlalchemy import outerjoin
+from sqlalchemy import select
+from sqlalchemy import Sequence
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import type_coerce
+from sqlalchemy import TypeDecorator
+from sqlalchemy import union
 from sqlalchemy import util
-from sqlalchemy.schema import Column, Table, MetaData
+from sqlalchemy.sql import column
+from sqlalchemy.sql import elements
+from sqlalchemy.sql import expression
+from sqlalchemy.sql import table
+from sqlalchemy.sql import util as sql_util
+from sqlalchemy.sql import visitors
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+
 
 metadata = MetaData()
 table1 = Table(
@@ -691,7 +719,8 @@ class SelectableTest(
         assert s.c.b is not None
         self.assert_compile(
             s.select(),
-            "SELECT b FROM (SELECT (SELECT table1.col1 AS a FROM table1) AS b)",
+            "SELECT b FROM "
+            "(SELECT (SELECT table1.col1 AS a FROM table1) AS b)",
         )
 
         s2 = select([s.label("c")])
@@ -1980,17 +2009,17 @@ class AnnotationsTest(fixtures.TestBase):
     def test_annotated_visit(self):
         table1 = table("table1", column("col1"), column("col2"))
 
-        bin = table1.c.col1 == bindparam("foo", value=None)
-        assert str(bin) == "table1.col1 = :foo"
+        bin_ = table1.c.col1 == bindparam("foo", value=None)
+        assert str(bin_) == "table1.col1 = :foo"
 
         def visit_binary(b):
             b.right = table1.c.col2
 
-        b2 = visitors.cloned_traverse(bin, {}, {"binary": visit_binary})
+        b2 = visitors.cloned_traverse(bin_, {}, {"binary": visit_binary})
         assert str(b2) == "table1.col1 = table1.col2"
 
         b3 = visitors.cloned_traverse(
-            bin._annotate({}), {}, {"binary": visit_binary}
+            bin_._annotate({}), {}, {"binary": visit_binary}
         )
         assert str(b3) == "table1.col1 = table1.col2"
 
@@ -2041,11 +2070,11 @@ class AnnotationsTest(fixtures.TestBase):
     def test_deannotate(self):
         table1 = table("table1", column("col1"), column("col2"))
 
-        bin = table1.c.col1 == bindparam("foo", value=None)
+        bin_ = table1.c.col1 == bindparam("foo", value=None)
 
-        b2 = sql_util._deep_annotate(bin, {"_orm_adapt": True})
+        b2 = sql_util._deep_annotate(bin_, {"_orm_adapt": True})
         b3 = sql_util._deep_deannotate(b2)
-        b4 = sql_util._deep_deannotate(bin)
+        b4 = sql_util._deep_deannotate(bin_)
 
         for elem in (b2._annotations, b2.left._annotations):
             assert "_orm_adapt" in elem
@@ -2058,12 +2087,12 @@ class AnnotationsTest(fixtures.TestBase):
         ):
             assert elem == {}
 
-        assert b2.left is not bin.left
-        assert b3.left is not b2.left and b2.left is not bin.left
-        assert b4.left is bin.left  # since column is immutable
+        assert b2.left is not bin_.left
+        assert b3.left is not b2.left and b2.left is not bin_.left
+        assert b4.left is bin_.left  # since column is immutable
         # deannotate copies the element
         assert (
-            bin.right is not b2.right
+            bin_.right is not b2.right
             and b2.right is not b3.right
             and b3.right is not b4.right
         )
index 712450d9f2c99ae90bfd489017ec2cd2cd7ba0ed..d2c57c93053581b0469636a454085f24480cf0a8 100644 (file)
@@ -1,10 +1,14 @@
-from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import AssertsCompiledSQL, assert_raises_message
-from sqlalchemy.sql import select, func, text
-from sqlalchemy.engine import default
-from sqlalchemy import exc
-from sqlalchemy import Table, Integer, String, Column
+from sqlalchemy import Column
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import tablesample
+from sqlalchemy.engine import default
+from sqlalchemy.sql import func
+from sqlalchemy.sql import select
+from sqlalchemy.sql import text
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import fixtures
 
 
 class TableSampleTest(fixtures.TablesTest, AssertsCompiledSQL):
index 34415600e8eb164ab7e652c7e327c8f9cdd6ab1f..6b419f59950a09544f2c0512f14910dc249526c0 100644 (file)
@@ -1,36 +1,34 @@
 """Test the TextClause and related constructs."""
 
-from sqlalchemy.testing import (
-    fixtures,
-    AssertsCompiledSQL,
-    eq_,
-    assert_raises_message,
-    expect_warnings,
-    assert_warnings,
-)
-from sqlalchemy import (
-    text,
-    select,
-    Integer,
-    String,
-    Float,
-    bindparam,
-    and_,
-    func,
-    literal_column,
-    exc,
-    MetaData,
-    Table,
-    Column,
-    asc,
-    func,
-    desc,
-    union,
-    literal,
-)
-from sqlalchemy.types import NullType
-from sqlalchemy.sql import table, column, util as sql_util
+from sqlalchemy import and_
+from sqlalchemy import asc
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import desc
+from sqlalchemy import exc
+from sqlalchemy import Float
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import literal_column
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy import text
+from sqlalchemy import union
 from sqlalchemy import util
+from sqlalchemy.sql import column
+from sqlalchemy.sql import table
+from sqlalchemy.sql import util as sql_util
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import assert_warnings
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
+from sqlalchemy.testing import fixtures
+from sqlalchemy.types import NullType
+
 
 table1 = table(
     "mytable",
index 8c5fb1f071fcdcb09085406a1559ce971eebccae..18877c338f917b6704a963e11b03ce1969202266 100644 (file)
@@ -1,16 +1,15 @@
-from sqlalchemy import (
-    Table,
-    Column,
-    String,
-    func,
-    MetaData,
-    select,
-    TypeDecorator,
-    cast,
-)
-from sqlalchemy.testing import fixtures, AssertsCompiledSQL
+from sqlalchemy import cast
+from sqlalchemy import Column
+from sqlalchemy import func
+from sqlalchemy import MetaData
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy import testing
+from sqlalchemy import TypeDecorator
+from sqlalchemy.testing import AssertsCompiledSQL
 from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
 
 
 class _ExprFixture(object):
index 179f1050c97d5aef5b7d2c6d94250df2e6cf51e9..c54fe1e549fd3f9e1b3d35c24ab8f0268b6546cd 100644 (file)
@@ -1,86 +1,89 @@
 # coding: utf-8
-from sqlalchemy.testing import (
-    eq_,
-    is_,
-    is_not_,
-    assert_raises,
-    assert_raises_message,
-    expect_warnings,
-)
-import decimal
 import datetime
+import decimal
+import importlib
+import operator
 import os
-from sqlalchemy import (
-    Unicode,
-    MetaData,
-    PickleType,
-    Boolean,
-    TypeDecorator,
-    Integer,
-    Interval,
-    Float,
-    Numeric,
-    Text,
-    CHAR,
-    String,
-    distinct,
-    select,
-    bindparam,
-    and_,
-    func,
-    Date,
-    LargeBinary,
-    literal,
-    cast,
-    text,
-    Enum,
-    type_coerce,
-    VARCHAR,
-    Time,
-    DateTime,
-    BigInteger,
-    SmallInteger,
-    BOOLEAN,
-    BLOB,
-    NCHAR,
-    NVARCHAR,
-    CLOB,
-    TIME,
-    DATE,
-    DATETIME,
-    TIMESTAMP,
-    SMALLINT,
-    INTEGER,
-    DECIMAL,
-    NUMERIC,
-    FLOAT,
-    REAL,
-    ARRAY,
-    JSON,
-)
-from sqlalchemy.sql import ddl
-from sqlalchemy.sql import visitors
+
+from sqlalchemy import and_
+from sqlalchemy import ARRAY
+from sqlalchemy import BigInteger
+from sqlalchemy import bindparam
+from sqlalchemy import BLOB
+from sqlalchemy import BOOLEAN
+from sqlalchemy import Boolean
+from sqlalchemy import cast
+from sqlalchemy import CHAR
+from sqlalchemy import CLOB
+from sqlalchemy import DATE
+from sqlalchemy import Date
+from sqlalchemy import DATETIME
+from sqlalchemy import DateTime
+from sqlalchemy import DECIMAL
+from sqlalchemy import dialects
+from sqlalchemy import distinct
+from sqlalchemy import Enum
+from sqlalchemy import exc
+from sqlalchemy import FLOAT
+from sqlalchemy import Float
+from sqlalchemy import func
 from sqlalchemy import inspection
-from sqlalchemy import exc, types, util, dialects
-from sqlalchemy.util import OrderedDict
-from sqlalchemy.sql import operators, column, table, null
-from sqlalchemy.schema import CheckConstraint, AddConstraint
-from sqlalchemy.engine import default
-from sqlalchemy.testing.schema import Table, Column
+from sqlalchemy import INTEGER
+from sqlalchemy import Integer
+from sqlalchemy import Interval
+from sqlalchemy import JSON
+from sqlalchemy import LargeBinary
+from sqlalchemy import literal
+from sqlalchemy import MetaData
+from sqlalchemy import NCHAR
+from sqlalchemy import NUMERIC
+from sqlalchemy import Numeric
+from sqlalchemy import NVARCHAR
+from sqlalchemy import PickleType
+from sqlalchemy import REAL
+from sqlalchemy import select
+from sqlalchemy import SMALLINT
+from sqlalchemy import SmallInteger
+from sqlalchemy import String
 from sqlalchemy import testing
-from sqlalchemy.testing import (
-    AssertsCompiledSQL,
-    AssertsExecutionResults,
-    engines,
-    pickleable,
-)
-from sqlalchemy.testing.util import picklers
-from sqlalchemy.testing.util import round_decimal
+from sqlalchemy import Text
+from sqlalchemy import text
+from sqlalchemy import TIME
+from sqlalchemy import Time
+from sqlalchemy import TIMESTAMP
+from sqlalchemy import type_coerce
+from sqlalchemy import TypeDecorator
+from sqlalchemy import types
+from sqlalchemy import Unicode
+from sqlalchemy import util
+from sqlalchemy import VARCHAR
+from sqlalchemy.engine import default
+from sqlalchemy.schema import AddConstraint
+from sqlalchemy.schema import CheckConstraint
+from sqlalchemy.sql import column
+from sqlalchemy.sql import ddl
+from sqlalchemy.sql import null
+from sqlalchemy.sql import operators
+from sqlalchemy.sql import sqltypes
+from sqlalchemy.sql import table
+from sqlalchemy.sql import visitors
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_warnings
 from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_
+from sqlalchemy.testing import is_not_
 from sqlalchemy.testing import mock
-from sqlalchemy.sql import column
-import operator
-import importlib
+from sqlalchemy.testing import pickleable
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.testing.util import picklers
+from sqlalchemy.testing.util import round_decimal
+from sqlalchemy.util import OrderedDict
 
 
 class AdaptTest(fixtures.TestBase):
@@ -198,8 +201,6 @@ class AdaptTest(fixtures.TestBase):
                     ):
                         yield True, subcl, [typ]
 
-        from sqlalchemy.sql import sqltypes
-
         for is_down_adaption, typ, target_adaptions in adaptions():
             if typ in (types.TypeDecorator, types.TypeEngine, types.Variant):
                 continue
@@ -2754,8 +2755,8 @@ class NumericRawSQLTest(fixtures.TestBase):
 
     """
 
-    def _fixture(self, metadata, type, data):
-        t = Table("t", metadata, Column("val", type))
+    def _fixture(self, metadata, type_, data):
+        t = Table("t", metadata, Column("val", type_))
         metadata.create_all()
         t.insert().execute(val=data)
 
index fafdb03a3ad26502c0a6ee377779929e5f2eb795..5b51644e678316de67050526c3af201f1d86ca94 100644 (file)
@@ -1,11 +1,18 @@
 # coding: utf-8
 """verrrrry basic unicode column name testing"""
 
-from sqlalchemy import *
-from sqlalchemy.testing import fixtures, engines, eq_
+from sqlalchemy import desc
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
 from sqlalchemy import testing
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy.util import u, ue
+from sqlalchemy.testing import engines
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
+from sqlalchemy.util import u
+from sqlalchemy.util import ue
 
 
 class UnicodeSchemaTest(fixtures.TestBase):
@@ -189,7 +196,8 @@ class UnicodeSchemaTest(fixtures.TestBase):
             repr(t),
             (
                 "Table('\\u6e2c\\u8a66', MetaData(bind=None), "
-                "Column('\\u6e2c\\u8a66_id', Integer(), table=<\u6e2c\u8a66>), "
+                "Column('\\u6e2c\\u8a66_id', Integer(), "
+                "table=<\u6e2c\u8a66>), "
                 "schema=None)"
             ),
         )
index 191ecb4d6bec1a86915585caa68944ff7d463722..514076daab3720eb8a8473c52f47c6bea0733669 100644 (file)
@@ -1,33 +1,30 @@
-from sqlalchemy import (
-    Integer,
-    String,
-    ForeignKey,
-    and_,
-    or_,
-    func,
-    literal,
-    update,
-    table,
-    bindparam,
-    column,
-    select,
-    exc,
-    exists,
-    text,
-    MetaData,
-)
+from sqlalchemy import and_
+from sqlalchemy import bindparam
+from sqlalchemy import column
+from sqlalchemy import exc
+from sqlalchemy import exists
+from sqlalchemy import ForeignKey
+from sqlalchemy import func
+from sqlalchemy import Integer
+from sqlalchemy import literal
+from sqlalchemy import MetaData
+from sqlalchemy import or_
+from sqlalchemy import select
+from sqlalchemy import String
+from sqlalchemy import table
 from sqlalchemy import testing
+from sqlalchemy import text
+from sqlalchemy import update
+from sqlalchemy import util
 from sqlalchemy.dialects import mysql
 from sqlalchemy.engine import default
-from sqlalchemy.testing import (
-    AssertsCompiledSQL,
-    eq_,
-    fixtures,
-    assert_raises_message,
-    assert_raises,
-)
-from sqlalchemy.testing.schema import Table, Column
-from sqlalchemy import util
+from sqlalchemy.testing import assert_raises
+from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import AssertsCompiledSQL
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing.schema import Column
+from sqlalchemy.testing.schema import Table
 
 
 class _UpdateFromTestBase(object):
index bc124ada97b574030dbb823f128dcb51f4b66c6c..023c483fcf2c89de1cdb76ecf713343769bfe3d9 100644 (file)
@@ -1,9 +1,19 @@
-from sqlalchemy.testing import fixtures, is_true, is_false, eq_
-from sqlalchemy import MetaData, Table, Column, Integer, String
-from sqlalchemy import and_, or_, bindparam
-from sqlalchemy.sql.elements import ClauseList, ColumnElement
+from sqlalchemy import and_
+from sqlalchemy import bindparam
+from sqlalchemy import Column
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import or_
+from sqlalchemy import String
+from sqlalchemy import Table
 from sqlalchemy.sql import operators
 from sqlalchemy.sql import util as sql_util
+from sqlalchemy.sql.elements import ClauseList
+from sqlalchemy.sql.elements import ColumnElement
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_false
+from sqlalchemy.testing import is_true
 
 
 class CompareClausesTest(fixtures.TestBase):