This commit is contained in:
2025-05-22 20:25:38 +02:00
parent 09f6750c2b
commit ce03fbf12f
529 changed files with 3353 additions and 3312 deletions

View File

@@ -205,7 +205,11 @@ class Connection(ConnectionEventsTarget, inspection.Inspectable["Inspector"]):
@property
def _schema_translate_map(self) -> Optional[SchemaTranslateMapType]:
return self._execution_options.get("schema_translate_map", None)
schema_translate_map: Optional[
SchemaTranslateMapType
] = self._execution_options.get("schema_translate_map", None)
return schema_translate_map
def schema_for_object(self, obj: HasSchemaAttr) -> Optional[str]:
"""Return the schema name for the given schema item taking into
@@ -814,7 +818,7 @@ class Connection(ConnectionEventsTarget, inspection.Inspectable["Inspector"]):
The above code is not fundamentally any different in its behavior than
the following code which does not use
:meth:`_engine.Connection.begin`; the below style is referred towards
:meth:`_engine.Connection.begin`; the below style is known
as "commit as you go" style::
with engine.connect() as conn:

View File

@@ -1995,7 +1995,7 @@ class CursorResult(Result[_T]):
* :attr:`_engine.CursorResult.rowcount`
is *only* useful in conjunction
with an UPDATE or DELETE statement. Contrary to what the Python
DBAPI says, it does *not* return the
DBAPI says, it does *not* reliably return the
number of rows available from the results of a SELECT statement
as DBAPIs cannot support this functionality when rows are
unbuffered.

View File

@@ -71,6 +71,7 @@ if typing.TYPE_CHECKING:
from types import ModuleType
from .base import Engine
from .cursor import ResultFetchStrategy
from .interfaces import _CoreMultiExecuteParams
from .interfaces import _CoreSingleExecuteParams
from .interfaces import _DBAPICursorDescription
@@ -135,7 +136,7 @@ class DefaultDialect(Dialect):
# most DBAPIs happy with this for execute().
# not cx_oracle.
execute_sequence_format = tuple # type: ignore
execute_sequence_format = tuple
supports_schemas = True
supports_views = True
@@ -1853,7 +1854,7 @@ class DefaultExecutionContext(ExecutionContext):
def _setup_dml_or_text_result(self):
compiled = cast(SQLCompiler, self.compiled)
strategy = self.cursor_fetch_strategy
strategy: ResultFetchStrategy = self.cursor_fetch_strategy
if self.isinsert:
if (
@@ -1882,9 +1883,15 @@ class DefaultExecutionContext(ExecutionContext):
strategy = _cursor.BufferedRowCursorFetchStrategy(
self.cursor, self.execution_options
)
cursor_description = (
strategy.alternate_cursor_description or self.cursor.description
)
if strategy is _cursor._NO_CURSOR_DML:
cursor_description = None
else:
cursor_description = (
strategy.alternate_cursor_description
or self.cursor.description
)
if cursor_description is None:
strategy = _cursor._NO_CURSOR_DML
elif self._num_sentinel_cols:
@@ -2232,7 +2239,7 @@ class DefaultExecutionContext(ExecutionContext):
and compile_state._has_multi_parameters
):
if column._is_multiparam_column:
index = column.index + 1 # type: ignore
index = column.index + 1
d = {column.original.key: parameters[column.key]}
else:
d = {column.key: parameters[column.key]}
@@ -2304,7 +2311,7 @@ class DefaultExecutionContext(ExecutionContext):
param[param_key] = arg
elif is_callable:
self.current_column = c
param[param_key] = arg(self) # type: ignore
param[param_key] = arg(self)
else:
val = fallback(c)
if val is not None:

View File

@@ -131,7 +131,7 @@ class ConnectionEvents(event.Events[ConnectionEventsTarget]):
if default_dispatch is None and hasattr(
target, "_no_async_engine_events"
):
target._no_async_engine_events() # type: ignore
target._no_async_engine_events()
return default_dispatch
@@ -640,7 +640,7 @@ class DialectEvents(event.Events[Dialect]):
_dispatch_target = Dialect
@classmethod
def _listen( # type: ignore
def _listen(
cls,
event_key: event._EventKey[Dialect],
*,

View File

@@ -521,7 +521,7 @@ class ReflectedIndex(TypedDict):
"""index name"""
column_names: List[Optional[str]]
"""column names which the index refers towards.
"""column names which the index references.
An element of this list is ``None`` if it's an expression and is
returned in the ``expressions`` list.
"""

View File

@@ -126,6 +126,6 @@ def create_mock_engine(
dialect_args[k] = kw.pop(k)
# create dialect
dialect = dialect_cls(**dialect_args) # type: ignore
dialect = dialect_cls(**dialect_args)
return MockConnection(dialect, executor)

View File

@@ -230,7 +230,7 @@ class Inspector(inspection.Inspectable["Inspector"]):
cls, init: Callable[..., Any], bind: Union[Engine, Connection]
) -> Inspector:
if hasattr(bind.dialect, "inspector"):
cls = bind.dialect.inspector # type: ignore[attr-defined]
cls = bind.dialect.inspector
self = cls.__new__(cls)
init(self, bind)
@@ -240,7 +240,7 @@ class Inspector(inspection.Inspectable["Inspector"]):
if hasattr(bind, "exec_driver_sql"):
self._init_connection(bind) # type: ignore[arg-type]
else:
self._init_engine(bind) # type: ignore[arg-type]
self._init_engine(bind)
def _init_engine(self, engine: Engine) -> None:
self.bind = self.engine = engine
@@ -1627,9 +1627,7 @@ class Inspector(inspection.Inspectable["Inspector"]):
orig_name = col_d["name"]
table.metadata.dispatch.column_reflect(self, table, col_d)
table.dispatch.column_reflect( # type: ignore[attr-defined]
self, table, col_d
)
table.dispatch.column_reflect(self, table, col_d)
# fetch name again as column_reflect is allowed to
# change it
@@ -2038,7 +2036,7 @@ class ReflectionDefaults:
@classmethod
def pk_constraint(cls) -> ReflectedPrimaryKeyConstraint:
return { # type: ignore # pep-655 not supported
return {
"name": None,
"constrained_columns": [],
}

View File

@@ -373,7 +373,7 @@ class SimpleResultMetaData(ResultMetaData):
indexes: Sequence[int]
new_keys: Sequence[str]
extra: Sequence[Any]
indexes, new_keys, extra = zip(*metadata_for_keys) # type: ignore
indexes, new_keys, extra = zip(*metadata_for_keys)
if self._translated_indexes:
indexes = [self._translated_indexes[idx] for idx in indexes]
@@ -459,7 +459,7 @@ class ResultInternal(InPlaceGenerative, Generic[_R]):
else:
_proc = Row
def process_row( # type: ignore
def process_row(
metadata: ResultMetaData,
processors: Optional[_ProcessorsType],
key_to_index: Mapping[_KeyType, int],

View File

@@ -48,7 +48,7 @@ def connection_memoize(key: str) -> Callable[[_C], _C]:
connection.info[key] = val = fn(self, connection)
return val
return decorated # type: ignore
return decorated
class _TConsSubject(Protocol):