diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-26 10:17:38 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-29 13:46:23 -0500 |
commit | db85d28a857945ce021e27a187a14999eeb5c89e (patch) | |
tree | 3e402d745aa1d01a51198154ddda25fe96296056 /lib/sqlalchemy/engine/reflection.py | |
parent | 5eb407f84bdabdbcd68975dbf76dc4c0809d7373 (diff) | |
download | sqlalchemy-db85d28a857945ce021e27a187a14999eeb5c89e.tar.gz |
provide connectionfairy on initialize
This is so that dialect methods that are called within init
can assume the same argument structure as when they are called
in other places; we can nail down the type of object as well.
This change seems to mostly impact the isolation level routines
in the dialects, as these are called during initialize()
as well as on established connections. these methods can now
assume a non-proxied DBAPI connection object in all cases,
as it is commonly required that attributes like ".autocommit"
are set on the object which don't work well in a proxied
situation.
Other changes:
* adds an interface for the "connectionfairy" concept
called PoolProxiedConnection.
* Removes ``Connectable`` superclass of Connection.
``Connectable`` was originally meant to provide for the
"method which accepts connection or engine" theme. As this
pattern is greatly reduced in 2.0 and Engine no longer extends
from it, the ``Connectable`` superclass doesnt serve any real
purpose.
Leading from that, to set this in I also applied pep 484 annotations
to the Dialect base, and then in the interests of seeing some
of the typing information show up in my IDE did a little bit for Engine,
Connection and others. I hope that it's feasible that we can
add annotations to specific classes and attributes ahead of when we
actually try to mass-populate the whole library. This was
the original spirit of pep-484 that we can apply annotations
gradually. I do of course want to try to do a mass-populate
although i think even in that case we will end up doing a lot
of manual work anyway (in particular for the changes here which
are distinct from what the stubs have).
Fixes: #7122
Change-Id: I5dd7fbff8a7ae520a81c165091af12a6a68826db
Diffstat (limited to 'lib/sqlalchemy/engine/reflection.py')
-rw-r--r-- | lib/sqlalchemy/engine/reflection.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index 7abc404f0..562130f77 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -27,7 +27,6 @@ methods such as get_table_names, get_columns, etc. import contextlib -from .base import Connectable from .base import Connection from .base import Engine from .. import exc @@ -96,7 +95,7 @@ class Inspector: def __init__(self, bind): """Initialize a new :class:`_reflection.Inspector`. - :param bind: a :class:`~sqlalchemy.engine.Connectable`, + :param bind: a :class:`~sqlalchemy.engine.Connection`, which is typically an instance of :class:`~sqlalchemy.engine.Engine` or :class:`~sqlalchemy.engine.Connection`. @@ -153,10 +152,8 @@ class Inspector: """Construct a new dialect-specific Inspector object from the given engine or connection. - :param bind: a :class:`~sqlalchemy.engine.Connectable`, - which is typically an instance of - :class:`~sqlalchemy.engine.Engine` or - :class:`~sqlalchemy.engine.Connection`. + :param bind: a :class:`~sqlalchemy.engine.Connection` + or :class:`~sqlalchemy.engine.Engine`. This method differs from direct a direct constructor call of :class:`_reflection.Inspector` in that the @@ -170,13 +167,6 @@ class Inspector: """ return cls._construct(cls._init_legacy, bind) - @inspection._inspects(Connectable) - def _connectable_insp(bind): - # this method should not be used unless some unusual case - # has subclassed "Connectable" - - return Inspector._construct(Inspector._init_legacy, bind) - @inspection._inspects(Engine) def _engine_insp(bind): return Inspector._construct(Inspector._init_engine, bind) |