From d663f4d5bd3685eb8e074b3ec8d9a5c7baba3d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bal=C3=A1=C5=BE?= Date: Sun, 22 Jan 2023 11:16:56 -0500 Subject: Result.__enter__ annotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed typing issue where the object type when using :class:`_engine.Result` as a context manager were not preserved, indicating :class:`_engine.Result` in all cases rather than the specific :class:`_engine.Result` sub-type. Pull request courtesy Martin Baláž. Fixes: #9136 Closes: #9135 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9135 Pull-request-sha: 97a9829db59db359fbb400ec0d913bdf8954f00a Change-Id: I60a7f89ba39bf0f9fc5e6e7bf09f642167fe476f --- lib/sqlalchemy/engine/result.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sqlalchemy/engine/result.py b/lib/sqlalchemy/engine/result.py index 4bf03ae69..67151913e 100644 --- a/lib/sqlalchemy/engine/result.py +++ b/lib/sqlalchemy/engine/result.py @@ -929,7 +929,7 @@ class Result(_WithKeys, ResultInternal[Row[_TP]]): def __init__(self, cursor_metadata: ResultMetaData): self._metadata = cursor_metadata - def __enter__(self) -> Result[_TP]: + def __enter__(self: SelfResult) -> SelfResult: return self def __exit__(self, type_: Any, value: Any, traceback: Any) -> None: -- cgit v1.2.1