timsaucer commented on code in PR #1277:
URL:
https://github.com/apache/datafusion-python/pull/1277#discussion_r2483678964
##########
python/datafusion/user_defined.py:
##########
@@ -22,15 +22,31 @@
import functools
from abc import ABCMeta, abstractmethod
from enum import Enum
-from typing import TYPE_CHECKING, Any, Callable, Optional, Protocol, TypeVar,
overload
+from typing import (
+ TYPE_CHECKING,
+ Any,
+ Callable,
+ Optional,
+ Protocol,
+ TypeVar,
+ cast,
+ overload,
+)
import pyarrow as pa
+from typing_extensions import TypeGuard
import datafusion._internal as df_internal
from datafusion.expr import Expr
if TYPE_CHECKING:
+ from _typeshed import CapsuleType as _PyCapsule
+
_R = TypeVar("_R", bound=pa.DataType)
+else:
+
+ class _PyCapsule:
+ """Lightweight typing proxy for CPython ``PyCapsule`` objects."""
Review Comment:
Yes, but I think this is okay because if the same file appropriately sets
future annotations it has no isse:
```python
from __future__ import annotations
from typing import TYPE_CHECKING, TypeGuard
if TYPE_CHECKING:
from _typeshed import CapsuleType as _PyCapsule
def is_capsule(obj: object) -> TypeGuard[_PyCapsule]:
return hasattr(obj, "__capsule__")
```
The first line prevents this error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]