Skip to content

Commit 6c00f07

Browse files
committed
feat: connection に __enter__ を追加しました。
1 parent 4cc2e18 commit 6c00f07

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from typing import Generic, TypeVar
22

3-
from turu.core.features import _NotSupportFeature
3+
import pandera.typing
44
from typing_extensions import TypeAlias
55

6+
from turu.core.features import _NotSupportFeature
7+
68
T = TypeVar("T")
79

810

@@ -48,6 +50,7 @@ class _NotSupportFeatureT(Generic[T]):
4850
from typing import TypeVar
4951

5052
import pandera # type: ignore[import] # noqa: F401
53+
import pandera.typing
5154

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

0 commit comments

Comments
 (0)