From b211bf31a3f4c8009160b50d5ab6b0a2ae14e8a5 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 10 May 2022 11:46:01 +0200 Subject: [PATCH] Update testing_engine() annotations (#7818) --- .../SQLAlchemy/@tests/stubtest_allowlist.txt | 3 ++ .../SQLAlchemy/sqlalchemy/testing/engines.pyi | 30 ++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt index 76d7bcc56..338b82c23 100644 --- a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt +++ b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt @@ -122,6 +122,9 @@ sqlalchemy.engine.base.Connection.engine sqlalchemy.engine.URL.normalized_query sqlalchemy.engine.url.URL.normalized_query +# runtime has extra internal arguments that are inconsistent across micro versions +sqlalchemy.testing.engines.testing_engine + # unclear problems sqlalchemy.sql.elements.quoted_name.lower sqlalchemy.sql.elements.quoted_name.upper diff --git a/stubs/SQLAlchemy/sqlalchemy/testing/engines.pyi b/stubs/SQLAlchemy/sqlalchemy/testing/engines.pyi index 2e87a4e23..1ca2dff85 100644 --- a/stubs/SQLAlchemy/sqlalchemy/testing/engines.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/testing/engines.pyi @@ -1,4 +1,10 @@ -from typing import Any +from collections.abc import Mapping +from typing import Any, overload +from typing_extensions import Literal + +from ..engine import Engine +from ..engine.url import URL +from ..ext.asyncio import AsyncEngine class ConnectionKiller: proxy_refs: Any @@ -37,14 +43,22 @@ class ReconnectFixture: def restart(self) -> None: ... def reconnecting_engine(url: Any | None = ..., options: Any | None = ...): ... -def testing_engine( - url: Any | None = ..., - options: Any | None = ..., - future: Any | None = ..., - asyncio: bool = ..., +@overload +def testing_engine( # type: ignore[misc] + url: URL | str | None = ..., + options: Mapping[str, Any] | None = ..., + future: bool | None = ..., + asyncio: Literal[False] = ..., transfer_staticpool: bool = ..., - _sqlite_savepoint: bool = ..., -): ... +) -> Engine: ... +@overload +def testing_engine( + url: URL | str | None = ..., + options: Mapping[str, Any] | None = ..., + future: bool | None = ..., + asyncio: Literal[True] = ..., + transfer_staticpool: bool = ..., +) -> AsyncEngine: ... def mock_engine(dialect_name: Any | None = ...): ... class DBAPIProxyCursor: