Skip to content

Commit 6f7290e

Browse files
authored
Merge pull request #244 from yassun7010/add_connection_enter
feat: connection に __enter__ を追加しました。
2 parents 4cc2e18 + 6a083c9 commit 6f7290e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

turu-core/src/turu/core/connection.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from abc import abstractmethod
22
from typing import Any, Optional, Sequence, Tuple, Type
33

4+
from typing_extensions import Never, Self, override
5+
46
import turu.core.cursor
57
from turu.core.protocols.connection import ConnectionProtocol
68
from turu.core.protocols.cursor import Parameters
7-
from typing_extensions import Never, Self, override
89

910

1011
class Connection(ConnectionProtocol):
@@ -125,3 +126,9 @@ def executemany_map(
125126
"""
126127

127128
return self.cursor().executemany_map(row_type, operation, seq_of_parameters)
129+
130+
def __enter__(self) -> Self:
131+
return self
132+
133+
def __exit__(self, exc_type, exc_value, traceback) -> None:
134+
self.close()

turu-snowflake/src/turu/snowflake/features.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from typing import Generic, TypeVar
22

3-
from turu.core.features import _NotSupportFeature
43
from typing_extensions import TypeAlias
54

5+
from turu.core.features import _NotSupportFeature
6+
67
T = TypeVar("T")
78

89

@@ -48,6 +49,7 @@ class _NotSupportFeatureT(Generic[T]):
4849
from typing import TypeVar
4950

5051
import pandera # type: ignore[import] # noqa: F401
52+
import pandera.typing # type: ignore[import] # noqa: F401
5153

5254
USE_PANDERA = True
5355
PanderaDataFrame: TypeAlias = pandera.typing.DataFrame[T] # type: ignore

0 commit comments

Comments
 (0)