diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-02-17 13:43:04 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-01 09:09:02 -0500 |
| commit | a4bb502cf95ea3523e4d383c4377e50f402d7d52 (patch) | |
| tree | 124400f741b6b91f0e9e582b510268607394dfaa /lib/sqlalchemy/dialects | |
| parent | 60fca2ac8cf44bdaf68552ab5c69854a6776c73c (diff) | |
| download | sqlalchemy-a4bb502cf95ea3523e4d383c4377e50f402d7d52.tar.gz | |
pep-484 for engine
All modules in sqlalchemy.engine are strictly
typed with the exception of cursor, default, and
reflection. cursor and default pass with non-strict
typing, reflection is waiting on the multi-reflection
refactor.
Behavioral changes:
* create_connect_args() methods return a tuple of list,
dict, rather than a list of list, dict
* removed allow_chars parameter from
pyodbc connector ._get_server_version_info()
method
* the parameter list passed to do_executemany is now
a list in all cases. previously, this was being run
through dialect.execute_sequence_format, which
defaults to tuple and was only intended for individual
tuple params.
* broke up dialect.dbapi into dialect.import_dbapi
class method and dialect.dbapi module object. added
a deprecation path for legacy dialects. it's not
really feasible to type a single attr as a classmethod
vs. module type. The "type_compiler" attribute also
has this problem with greater ability to work around,
left that one for now.
* lots of constants changing to be Enum, so that we can
type them. for fixed tuple-position constants in
cursor.py / compiler.py (which are used to avoid the
speed overhead of namedtuple), using Literal[value]
which seems to work well
* some tightening up in Row regarding __getitem__, which
we can do since we are on full 2.0 style result use
* altered the set_connection_execution_options and
set_engine_execution_options event flows so that the
dictionary of options may be mutated within the event
hook, where it will then take effect as the actual
options used. Previously, changing the dict would
be silently ignored which seems counter-intuitive
and not very useful.
* A lot of DefaultDialect/DefaultExecutionContext
methods and attributes, including underscored ones, move
to interfaces. This is not fully ideal as it means
the Dialect/ExecutionContext interfaces aren't publicly
subclassable directly, but their current purpose
is more of documentation for dialect authors who should
(and certainly are) still be subclassing the DefaultXYZ
versions in all cases
Overall, Result was the most extremely difficult class
hierarchy to type here as this hierarchy passes through
largely amorphous "row" datatypes throughout, which
can in fact by all kinds of different things, like
raw DBAPI rows, or Row objects, or "scalar"/Any, but
at the same time these types have meaning so I tried still
maintaining some level of semantic markings for these,
it highlights how complex Result is now, as it's trying
to be extremely efficient and inlined while also being
very open-ended and extensible.
Change-Id: I98b75c0c09eab5355fc7a33ba41dd9874274f12a
Diffstat (limited to 'lib/sqlalchemy/dialects')
19 files changed, 21 insertions, 21 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/pymssql.py b/lib/sqlalchemy/dialects/mssql/pymssql.py index 20d2b09db..8d654b72d 100644 --- a/lib/sqlalchemy/dialects/mssql/pymssql.py +++ b/lib/sqlalchemy/dialects/mssql/pymssql.py @@ -77,7 +77,7 @@ class MSDialect_pymssql(MSDialect): ) @classmethod - def dbapi(cls): + def import_dbapi(cls): module = __import__("pymssql") # pymmsql < 2.1.1 doesn't have a Binary method. we use string client_ver = tuple(int(x) for x in module.__version__.split(".")) @@ -106,7 +106,7 @@ class MSDialect_pymssql(MSDialect): port = opts.pop("port", None) if port and "host" in opts: opts["host"] = "%s:%s" % (opts["host"], port) - return [[], opts] + return ([], opts) def is_disconnect(self, e, connection, cursor): for msg in ( diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index 3af083a6a..0951f219b 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -538,7 +538,7 @@ class MSDialect_pyodbc(PyODBCConnector, MSDialect): # 2008. Before we had the VARCHAR cast above, pyodbc would also # fail on this query. return super(MSDialect_pyodbc, self)._get_server_version_info( - connection, allow_chars=False + connection ) else: version = [] diff --git a/lib/sqlalchemy/dialects/mysql/aiomysql.py b/lib/sqlalchemy/dialects/mysql/aiomysql.py index df716346e..d685b7ea1 100644 --- a/lib/sqlalchemy/dialects/mysql/aiomysql.py +++ b/lib/sqlalchemy/dialects/mysql/aiomysql.py @@ -276,7 +276,7 @@ class MySQLDialect_aiomysql(MySQLDialect_pymysql): is_async = True @classmethod - def dbapi(cls): + def import_dbapi(cls): return AsyncAdapt_aiomysql_dbapi( __import__("aiomysql"), __import__("pymysql") ) diff --git a/lib/sqlalchemy/dialects/mysql/asyncmy.py b/lib/sqlalchemy/dialects/mysql/asyncmy.py index 915b666bb..7d5b1bf86 100644 --- a/lib/sqlalchemy/dialects/mysql/asyncmy.py +++ b/lib/sqlalchemy/dialects/mysql/asyncmy.py @@ -288,7 +288,7 @@ class MySQLDialect_asyncmy(MySQLDialect_pymysql): is_async = True @classmethod - def dbapi(cls): + def import_dbapi(cls): return AsyncAdapt_asyncmy_dbapi(__import__("asyncmy")) @classmethod diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 5c2de0911..b2ccfc90f 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -2434,7 +2434,7 @@ class MySQLDialect(default.DefaultDialect): @classmethod def _is_mariadb_from_url(cls, url): - dbapi = cls.dbapi() + dbapi = cls.import_dbapi() dialect = cls(dbapi=dbapi) cargs, cparams = dialect.create_connect_args(url) diff --git a/lib/sqlalchemy/dialects/mysql/cymysql.py b/lib/sqlalchemy/dialects/mysql/cymysql.py index 9fd0b4a09..281c509b7 100644 --- a/lib/sqlalchemy/dialects/mysql/cymysql.py +++ b/lib/sqlalchemy/dialects/mysql/cymysql.py @@ -53,7 +53,7 @@ class MySQLDialect_cymysql(MySQLDialect_mysqldb): colspecs = util.update_copy(MySQLDialect.colspecs, {BIT: _cymysqlBIT}) @classmethod - def dbapi(cls): + def import_dbapi(cls): return __import__("cymysql") def _detect_charset(self, connection): diff --git a/lib/sqlalchemy/dialects/mysql/mariadbconnector.py b/lib/sqlalchemy/dialects/mysql/mariadbconnector.py index fca91204f..bf2b04251 100644 --- a/lib/sqlalchemy/dialects/mysql/mariadbconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mariadbconnector.py @@ -111,7 +111,7 @@ class MySQLDialect_mariadbconnector(MySQLDialect): ) @classmethod - def dbapi(cls): + def import_dbapi(cls): return __import__("mariadb") def is_disconnect(self, e, connection, cursor): diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py index c96b739dc..a69dac9a5 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py @@ -77,7 +77,7 @@ class MySQLDialect_mysqlconnector(MySQLDialect): colspecs = util.update_copy(MySQLDialect.colspecs, {BIT: _myconnpyBIT}) @classmethod - def dbapi(cls): + def import_dbapi(cls): from mysql import connector return connector diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py index b4f071de0..6d66f88b4 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqldb.py +++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py @@ -159,7 +159,7 @@ class MySQLDialect_mysqldb(MySQLDialect): return False @classmethod - def dbapi(cls): + def import_dbapi(cls): return __import__("MySQLdb") def on_connect(self): diff --git a/lib/sqlalchemy/dialects/mysql/pymysql.py b/lib/sqlalchemy/dialects/mysql/pymysql.py index eddb9c921..9a240da61 100644 --- a/lib/sqlalchemy/dialects/mysql/pymysql.py +++ b/lib/sqlalchemy/dialects/mysql/pymysql.py @@ -57,7 +57,7 @@ class MySQLDialect_pymysql(MySQLDialect_mysqldb): return False @classmethod - def dbapi(cls): + def import_dbapi(cls): return __import__("pymysql") def create_connect_args(self, url, _translate_args=None): diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index a390099ae..98181051e 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -963,7 +963,7 @@ class OracleDialect_cx_oracle(OracleDialect): return (0, 0, 0) @classmethod - def dbapi(cls): + def import_dbapi(cls): import cx_Oracle return cx_Oracle diff --git a/lib/sqlalchemy/dialects/postgresql/asyncpg.py b/lib/sqlalchemy/dialects/postgresql/asyncpg.py index 4c3c47ba6..75f6c2704 100644 --- a/lib/sqlalchemy/dialects/postgresql/asyncpg.py +++ b/lib/sqlalchemy/dialects/postgresql/asyncpg.py @@ -878,7 +878,7 @@ class PGDialect_asyncpg(PGDialect): return (99, 99, 99) @classmethod - def dbapi(cls): + def import_dbapi(cls): return AsyncAdapt_asyncpg_dbapi(__import__("asyncpg")) @util.memoized_property diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index c23da93bb..372b8639e 100644 --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py @@ -426,7 +426,7 @@ class PGDialect_pg8000(PGDialect): return (99, 99, 99) @classmethod - def dbapi(cls): + def import_dbapi(cls): return __import__("pg8000") def create_connect_args(self, url): diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg.py b/lib/sqlalchemy/dialects/postgresql/psycopg.py index 3ba535d6c..33dc65afc 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg.py @@ -281,7 +281,7 @@ class PGDialect_psycopg(_PGDialect_common_psycopg): register_hstore(info, connection.connection) @classmethod - def dbapi(cls): + def import_dbapi(cls): import psycopg return psycopg @@ -592,7 +592,7 @@ class PGDialectAsync_psycopg(PGDialect_psycopg): supports_statement_cache = True @classmethod - def dbapi(cls): + def import_dbapi(cls): import psycopg from psycopg.pq import ExecStatus diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py index a08c5e5b0..dddce5a62 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py @@ -612,7 +612,7 @@ class PGDialect_psycopg2(_PGDialect_common_psycopg): ) @classmethod - def dbapi(cls): + def import_dbapi(cls): import psycopg2 return psycopg2 diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py b/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py index 5a4dcb2e6..0943613a2 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py @@ -44,7 +44,7 @@ class PGDialect_psycopg2cffi(PGDialect_psycopg2): ) @classmethod - def dbapi(cls): + def import_dbapi(cls): return __import__("psycopg2cffi") @util.memoized_property diff --git a/lib/sqlalchemy/dialects/sqlite/aiosqlite.py b/lib/sqlalchemy/dialects/sqlite/aiosqlite.py index e88ab1a0f..dd0499975 100644 --- a/lib/sqlalchemy/dialects/sqlite/aiosqlite.py +++ b/lib/sqlalchemy/dialects/sqlite/aiosqlite.py @@ -308,7 +308,7 @@ class SQLiteDialect_aiosqlite(SQLiteDialect_pysqlite): execution_ctx_cls = SQLiteExecutionContext_aiosqlite @classmethod - def dbapi(cls): + def import_dbapi(cls): return AsyncAdapt_aiosqlite_dbapi( __import__("aiosqlite"), __import__("sqlite3") ) diff --git a/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py b/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py index 28f795298..b67eed974 100644 --- a/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py +++ b/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py @@ -105,7 +105,7 @@ class SQLiteDialect_pysqlcipher(SQLiteDialect_pysqlite): pragmas = ("kdf_iter", "cipher", "cipher_page_size", "cipher_use_hmac") @classmethod - def dbapi(cls): + def import_dbapi(cls): try: import sqlcipher3 as sqlcipher except ImportError: diff --git a/lib/sqlalchemy/dialects/sqlite/pysqlite.py b/lib/sqlalchemy/dialects/sqlite/pysqlite.py index 8476e6834..2aa7149a6 100644 --- a/lib/sqlalchemy/dialects/sqlite/pysqlite.py +++ b/lib/sqlalchemy/dialects/sqlite/pysqlite.py @@ -465,7 +465,7 @@ class SQLiteDialect_pysqlite(SQLiteDialect): driver = "pysqlite" @classmethod - def dbapi(cls): + def import_dbapi(cls): from sqlite3 import dbapi2 as sqlite return sqlite |
