summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-05 12:29:33 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-01-05 12:29:33 -0500
commit6673a213daa02ade815d00a19e39edc6cee1466a (patch)
tree5a0c690772ac2566951236aef5e8cba85686d494
parentff3c72816938e8ef6500ade2f3977c5e2b7ada65 (diff)
downloadsqlalchemy-6673a213daa02ade815d00a19e39edc6cee1466a.tar.gz
Straight zimports run on examples
Change-Id: Id318122cb360b58604a658f3de1e5fce8b4a3e33
-rw-r--r--examples/adjacency_list/adjacency_list.py11
-rw-r--r--examples/association/basic_association.py21
-rw-r--r--examples/association/dict_of_sets_with_default.py16
-rw-r--r--examples/association/proxied_association.py21
-rw-r--r--examples/custom_attributes/custom_management.py32
-rw-r--r--examples/dogpile_caching/advanced.py6
-rw-r--r--examples/dogpile_caching/caching_query.py2
-rw-r--r--examples/dogpile_caching/environment.py15
-rw-r--r--examples/dogpile_caching/fixture_data.py10
-rw-r--r--examples/dogpile_caching/helloworld.py2
-rw-r--r--examples/dogpile_caching/local_session_caching.py3
-rw-r--r--examples/dogpile_caching/model.py9
-rw-r--r--examples/dogpile_caching/relationship_caching.py10
-rw-r--r--examples/dynamic_dict/dynamic_dict.py9
-rw-r--r--examples/elementtree/adjacency_list.py32
-rw-r--r--examples/elementtree/optimized_al.py32
-rw-r--r--examples/elementtree/pickle.py25
-rw-r--r--examples/generic_associations/discriminator_on_association.py13
-rw-r--r--examples/generic_associations/generic_fk.py15
-rw-r--r--examples/generic_associations/table_per_association.py20
-rw-r--r--examples/generic_associations/table_per_related.py12
-rw-r--r--examples/graphs/directed_graph.py8
-rw-r--r--examples/inheritance/concrete.py22
-rw-r--r--examples/inheritance/joined.py20
-rw-r--r--examples/inheritance/single.py23
-rw-r--r--examples/join_conditions/cast.py2
-rw-r--r--examples/join_conditions/threeway.py2
-rw-r--r--examples/large_collection/large_collection.py20
-rw-r--r--examples/materialized_paths/materialized_paths.py14
-rw-r--r--examples/nested_sets/nested_sets.py21
-rw-r--r--examples/performance/__init__.py4
-rw-r--r--examples/performance/bulk_inserts.py10
-rw-r--r--examples/performance/bulk_updates.py9
-rw-r--r--examples/performance/large_resultsets.py12
-rw-r--r--examples/performance/short_selects.py24
-rw-r--r--examples/performance/single_inserts.py11
-rw-r--r--examples/postgis/postgis.py9
-rw-r--r--examples/sharding/attribute_shard.py32
-rw-r--r--examples/versioned_history/history_meta.py16
-rw-r--r--examples/versioned_history/test_versioning.py42
-rw-r--r--examples/versioned_rows/versioned_map.py26
-rw-r--r--examples/versioned_rows/versioned_rows.py20
-rw-r--r--examples/versioned_rows/versioned_rows_w_versionid.py34
-rw-r--r--examples/versioned_rows/versioned_update_old_row.py37
-rw-r--r--examples/vertical/dictlike-polymorphic.py5
45 files changed, 418 insertions, 321 deletions
diff --git a/examples/adjacency_list/adjacency_list.py b/examples/adjacency_list/adjacency_list.py
index f1628a632..8cdd88540 100644
--- a/examples/adjacency_list/adjacency_list.py
+++ b/examples/adjacency_list/adjacency_list.py
@@ -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
diff --git a/examples/association/basic_association.py b/examples/association/basic_association.py
index 52476f184..56f676450 100644
--- a/examples/association/basic_association.py
+++ b/examples/association/basic_association.py
@@ -12,18 +12,17 @@ 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()
diff --git a/examples/association/dict_of_sets_with_default.py b/examples/association/dict_of_sets_with_default.py
index 7f668c087..435761d3f 100644
--- a/examples/association/dict_of_sets_with_default.py
+++ b/examples/association/dict_of_sets_with_default.py
@@ -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)
diff --git a/examples/association/proxied_association.py b/examples/association/proxied_association.py
index 46785c6e2..b1803bb15 100644
--- a/examples/association/proxied_association.py
+++ b/examples/association/proxied_association.py
@@ -7,18 +7,17 @@ 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()
diff --git a/examples/custom_attributes/custom_management.py b/examples/custom_attributes/custom_management.py
index 812385906..6cddfe7bd 100644
--- a/examples/custom_attributes/custom_management.py
+++ b/examples/custom_attributes/custom_management.py
@@ -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):
diff --git a/examples/dogpile_caching/advanced.py b/examples/dogpile_caching/advanced.py
index 8f395bd7b..92733b721 100644
--- a/examples/dogpile_caching/advanced.py
+++ b/examples/dogpile_caching/advanced.py
@@ -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):
diff --git a/examples/dogpile_caching/caching_query.py b/examples/dogpile_caching/caching_query.py
index 060c14613..1b85d7487 100644
--- a/examples/dogpile_caching/caching_query.py
+++ b/examples/dogpile_caching/caching_query.py
@@ -17,9 +17,9 @@ 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):
diff --git a/examples/dogpile_caching/environment.py b/examples/dogpile_caching/environment.py
index 13bd0a310..6e34315b5 100644
--- a/examples/dogpile_caching/environment.py
+++ b/examples/dogpile_caching/environment.py
@@ -2,15 +2,18 @@
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:
diff --git a/examples/dogpile_caching/fixture_data.py b/examples/dogpile_caching/fixture_data.py
index e301db2a4..3bc6790d9 100644
--- a/examples/dogpile_caching/fixture_data.py
+++ b/examples/dogpile_caching/fixture_data.py
@@ -3,10 +3,16 @@ 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)
diff --git a/examples/dogpile_caching/helloworld.py b/examples/dogpile_caching/helloworld.py
index eb565344e..848209486 100644
--- a/examples/dogpile_caching/helloworld.py
+++ b/examples/dogpile_caching/helloworld.py
@@ -2,9 +2,9 @@
"""
+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....")
diff --git a/examples/dogpile_caching/local_session_caching.py b/examples/dogpile_caching/local_session_caching.py
index 358886bf0..1700c7a63 100644
--- a/examples/dogpile_caching/local_session_caching.py
+++ b/examples/dogpile_caching/local_session_caching.py
@@ -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
diff --git a/examples/dogpile_caching/model.py b/examples/dogpile_caching/model.py
index f6a259820..4f79df196 100644
--- a/examples/dogpile_caching/model.py
+++ b/examples/dogpile_caching/model.py
@@ -7,10 +7,15 @@ 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):
diff --git a/examples/dogpile_caching/relationship_caching.py b/examples/dogpile_caching/relationship_caching.py
index 76c7e767f..76c22f3c1 100644
--- a/examples/dogpile_caching/relationship_caching.py
+++ b/examples/dogpile_caching/relationship_caching.py
@@ -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
):
diff --git a/examples/dynamic_dict/dynamic_dict.py b/examples/dynamic_dict/dynamic_dict.py
index 62da55c38..c35931535 100644
--- a/examples/dynamic_dict/dynamic_dict.py
+++ b/examples/dynamic_dict/dynamic_dict.py
@@ -29,9 +29,14 @@ class ProxyDict(object):
self.collection.append(value)
+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 import create_engine, Column, Integer, String, ForeignKey
-from sqlalchemy.orm import sessionmaker, relationship
+from sqlalchemy.orm import relationship
+from sqlalchemy.orm import sessionmaker
engine = create_engine("sqlite://", echo=True)
Base = declarative_base(engine)
diff --git a/examples/elementtree/adjacency_list.py b/examples/elementtree/adjacency_list.py
index 1f7161212..ee92cdaba 100644
--- a/examples/elementtree/adjacency_list.py
+++ b/examples/elementtree/adjacency_list.py
@@ -15,23 +15,25 @@ styles of persistence are identical, as is the structure of the main Document cl
"""
################################# 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
-
-import sys, os, io, re
-
+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://")
meta = MetaData()
diff --git a/examples/elementtree/optimized_al.py b/examples/elementtree/optimized_al.py
index 8e9c48b96..586a0be32 100644
--- a/examples/elementtree/optimized_al.py
+++ b/examples/elementtree/optimized_al.py
@@ -8,23 +8,25 @@
"""
##################### 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
-
+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()
diff --git a/examples/elementtree/pickle.py b/examples/elementtree/pickle.py
index a86fe30e5..cf3ea3c88 100644
--- a/examples/elementtree/pickle.py
+++ b/examples/elementtree/pickle.py
@@ -6,21 +6,20 @@ structure in distinct rows using two additional mapped entities. Note that the
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 sys, os
-
+import os
+import sys
from xml.etree import ElementTree
+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
+
e = create_engine("sqlite://")
meta = MetaData()
diff --git a/examples/generic_associations/discriminator_on_association.py b/examples/generic_associations/discriminator_on_association.py
index 38f2370f3..950208846 100644
--- a/examples/generic_associations/discriminator_on_association.py
+++ b/examples/generic_associations/discriminator_on_association.py
@@ -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()
diff --git a/examples/generic_associations/generic_fk.py b/examples/generic_associations/generic_fk.py
index ded8f749d..23145ed4c 100644
--- a/examples/generic_associations/generic_fk.py
+++ b/examples/generic_associations/generic_fk.py
@@ -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()
diff --git a/examples/generic_associations/table_per_association.py b/examples/generic_associations/table_per_association.py
index 7de246934..98c76ef7b 100644
--- a/examples/generic_associations/table_per_association.py
+++ b/examples/generic_associations/table_per_association.py
@@ -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()
diff --git a/examples/generic_associations/table_per_related.py b/examples/generic_associations/table_per_related.py
index 9c5e0e179..3f09e538b 100644
--- a/examples/generic_associations/table_per_related.py
+++ b/examples/generic_associations/table_per_related.py
@@ -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()
diff --git a/examples/graphs/directed_graph.py b/examples/graphs/directed_graph.py
index af85a4295..b40dbe39d 100644
--- a/examples/graphs/directed_graph.py
+++ b/examples/graphs/directed_graph.py
@@ -1,8 +1,12 @@
"""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()
diff --git a/examples/inheritance/concrete.py b/examples/inheritance/concrete.py
index 2245aa4e0..4eb89984a 100644
--- a/examples/inheritance/concrete.py
+++ b/examples/inheritance/concrete.py
@@ -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()
diff --git a/examples/inheritance/joined.py b/examples/inheritance/joined.py
index a3a61d763..09fc1a0cf 100644
--- a/examples/inheritance/joined.py
+++ b/examples/inheritance/joined.py
@@ -1,16 +1,16 @@
"""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()
diff --git a/examples/inheritance/single.py b/examples/inheritance/single.py
index 46d690c94..3466611eb 100644
--- a/examples/inheritance/single.py
+++ b/examples/inheritance/single.py
@@ -1,16 +1,17 @@
"""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()
diff --git a/examples/join_conditions/cast.py b/examples/join_conditions/cast.py
index 7ea775689..d4801fab2 100644
--- a/examples/join_conditions/cast.py
+++ b/examples/join_conditions/cast.py
@@ -30,8 +30,8 @@ in order to note to the ORM that ``B.a_id`` should be treated like the
"""
from sqlalchemy import *
-from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import *
Base = declarative_base()
diff --git a/examples/join_conditions/threeway.py b/examples/join_conditions/threeway.py
index 257002637..342a6cf89 100644
--- a/examples/join_conditions/threeway.py
+++ b/examples/join_conditions/threeway.py
@@ -34,8 +34,8 @@ a Query (or a :func:`.relationship`).
"""
from sqlalchemy import *
-from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import *
Base = declarative_base()
diff --git a/examples/large_collection/large_collection.py b/examples/large_collection/large_collection.py
index eb014c6cb..2cdb63bbb 100644
--- a/examples/large_collection/large_collection.py
+++ b/examples/large_collection/large_collection.py
@@ -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()
diff --git a/examples/materialized_paths/materialized_paths.py b/examples/materialized_paths/materialized_paths.py
index 45ae0c193..0bea6ccdf 100644
--- a/examples/materialized_paths/materialized_paths.py
+++ b/examples/materialized_paths/materialized_paths.py
@@ -26,11 +26,19 @@ 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()
diff --git a/examples/nested_sets/nested_sets.py b/examples/nested_sets/nested_sets.py
index 705a3d279..e94f6a301 100644
--- a/examples/nested_sets/nested_sets.py
+++ b/examples/nested_sets/nested_sets.py
@@ -4,18 +4,17 @@ 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()
diff --git a/examples/performance/__init__.py b/examples/performance/__init__.py
index b66199f3c..b817c313a 100644
--- a/examples/performance/__init__.py
+++ b/examples/performance/__init__.py
@@ -220,11 +220,11 @@ As well as see RunSnake output for an individual test::
"""
import argparse
import cProfile
-import pstats
import os
-import time
+import pstats
import re
import sys
+import time
class Profiler(object):
diff --git a/examples/performance/bulk_inserts.py b/examples/performance/bulk_inserts.py
index 52f0f32e6..872381376 100644
--- a/examples/performance/bulk_inserts.py
+++ b/examples/performance/bulk_inserts.py
@@ -3,12 +3,16 @@ 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
diff --git a/examples/performance/bulk_updates.py b/examples/performance/bulk_updates.py
index ebb700068..5f5b0ec14 100644
--- a/examples/performance/bulk_updates.py
+++ b/examples/performance/bulk_updates.py
@@ -3,12 +3,15 @@ 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
diff --git a/examples/performance/large_resultsets.py b/examples/performance/large_resultsets.py
index ad1c23194..835b063c1 100644
--- a/examples/performance/large_resultsets.py
+++ b/examples/performance/large_resultsets.py
@@ -13,11 +13,15 @@ full blown ORM doesn't do terribly either even though mapped objects
provide a huge amount of functionality.
"""
-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
-from sqlalchemy.orm import Session, Bundle
+from sqlalchemy.orm import Bundle
+from sqlalchemy.orm import Session
+
+from . import Profiler
Base = declarative_base()
engine = None
diff --git a/examples/performance/short_selects.py b/examples/performance/short_selects.py
index 4a8d401ad..3ea11f0d1 100644
--- a/examples/performance/short_selects.py
+++ b/examples/performance/short_selects.py
@@ -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
diff --git a/examples/performance/single_inserts.py b/examples/performance/single_inserts.py
index 79e34dfe6..eb035de5b 100644
--- a/examples/performance/single_inserts.py
+++ b/examples/performance/single_inserts.py
@@ -4,12 +4,17 @@ 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
diff --git a/examples/postgis/postgis.py b/examples/postgis/postgis.py
index 508d63398..bcea822b3 100644
--- a/examples/postgis/postgis.py
+++ b/examples/postgis/postgis.py
@@ -1,8 +1,11 @@
-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
diff --git a/examples/sharding/attribute_shard.py b/examples/sharding/attribute_shard.py
index 48a3dc932..6e47f8986 100644
--- a/examples/sharding/attribute_shard.py
+++ b/examples/sharding/attribute_shard.py
@@ -1,21 +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
-from sqlalchemy import inspect
-
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
+
# db1 is used for id generation. The "pool_threadlocal"
# causes the id_generator() to use the same connection as that
# of an ongoing transaction within db1.
diff --git a/examples/versioned_history/history_meta.py b/examples/versioned_history/history_meta.py
index 749a6a5ca..e2bcdc90d 100644
--- a/examples/versioned_history/history_meta.py
+++ b/examples/versioned_history/history_meta.py
@@ -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
diff --git a/examples/versioned_history/test_versioning.py b/examples/versioned_history/test_versioning.py
index 3270ad5fd..5e19130cf 100644
--- a/examples/versioned_history/test_versioning.py
+++ b/examples/versioned_history/test_versioning.py
@@ -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")
diff --git a/examples/versioned_rows/versioned_map.py b/examples/versioned_rows/versioned_map.py
index 46bdbb783..9abbb3e09 100644
--- a/examples/versioned_rows/versioned_map.py
+++ b/examples/versioned_rows/versioned_map.py
@@ -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")
diff --git a/examples/versioned_rows/versioned_rows.py b/examples/versioned_rows/versioned_rows.py
index 03e1c3510..01067431c 100644
--- a/examples/versioned_rows/versioned_rows.py
+++ b/examples/versioned_rows/versioned_rows.py
@@ -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):
diff --git a/examples/versioned_rows/versioned_rows_w_versionid.py b/examples/versioned_rows/versioned_rows_w_versionid.py
index 5fd6f9fc4..4861fb366 100644
--- a/examples/versioned_rows/versioned_rows_w_versionid.py
+++ b/examples/versioned_rows/versioned_rows_w_versionid.py
@@ -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):
diff --git a/examples/versioned_rows/versioned_update_old_row.py b/examples/versioned_rows/versioned_update_old_row.py
index 17c82fdc3..a3347f7a4 100644
--- a/examples/versioned_rows/versioned_update_old_row.py
+++ b/examples/versioned_rows/versioned_update_old_row.py
@@ -5,29 +5,26 @@ 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
diff --git a/examples/vertical/dictlike-polymorphic.py b/examples/vertical/dictlike-polymorphic.py
index c000ff3cf..dc1a941d6 100644
--- a/examples/vertical/dictlike-polymorphic.py
+++ b/examples/vertical/dictlike-polymorphic.py
@@ -24,10 +24,11 @@ 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