Skip to content

Commit 712d7d7

Browse files
committed
Refactor _PyCapsule definition for clarity and organization
1 parent 89f9859 commit 712d7d7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

python/datafusion/user_defined.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@
4141
from datafusion.expr import Expr
4242

4343
if TYPE_CHECKING:
44+
from _typeshed import CapsuleType as _PyCapsule
45+
4446
_R = TypeVar("_R", bound=pa.DataType)
47+
else:
48+
49+
class _PyCapsule:
50+
"""Lightweight typing proxy for CPython ``PyCapsule`` objects."""
4551

4652

4753
class Volatility(Enum):
@@ -94,10 +100,6 @@ class ScalarUDFExportable(Protocol):
94100
def __datafusion_scalar_udf__(self) -> object: ... # noqa: D105
95101

96102

97-
class _PyCapsule(Protocol):
98-
"""Lightweight typing proxy for CPython ``PyCapsule`` objects."""
99-
100-
101103
def _is_pycapsule(value: object) -> TypeGuard[_PyCapsule]:
102104
"""Return ``True`` when ``value`` is a CPython ``PyCapsule``."""
103105

0 commit comments

Comments
 (0)