Skip to content

Commit 9adbf4f

Browse files
committed
refactor: simplify type hints by removing unnecessary imports for type checking
1 parent 28619d9 commit 9adbf4f

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

python/datafusion/expr.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,9 @@
4040
if TYPE_CHECKING:
4141
from collections.abc import Sequence
4242

43-
# These are only imported for type checking to avoid runtime
44-
# evaluation issues with typing constructs.
43+
# Type-only imports
4544
from datafusion.common import DataTypeMap, RexType
46-
# Make the datafusion package available to type checkers for
47-
# fully-qualified string-literal annotations.
48-
import datafusion # type: ignore
4945
from datafusion.plan import LogicalPlan
50-
# Note: DataTypeMap and RexType are only available for type checking.
51-
# We intentionally avoid importing them at runtime to prevent evaluation
52-
# issues with complex typing constructs.
5346

5447

5548
# Standard error message for invalid expression types
@@ -655,23 +648,23 @@ def between(self, low: Any, high: Any, negated: bool = False) -> Expr:
655648

656649
return Expr(self.expr.between(low.expr, high.expr, negated=negated))
657650

658-
def rex_type(self) -> "datafusion.common.RexType":
651+
def rex_type(self) -> "RexType": # type: ignore[call-arg]
659652
"""Return the Rex Type of this expression.
660653
661654
A Rex (Row Expression) specifies a single row of data.That specification
662655
could include user defined functions or types. RexType identifies the
663656
row as one of the possible valid ``RexType``.
664657
"""
665-
return self.expr.rex_type()
658+
return self.expr.rex_type() # type: ignore
666659

667-
def types(self) -> "datafusion.common.DataTypeMap":
660+
def types(self) -> "DataTypeMap": # type: ignore[call-arg]
668661
"""Return the ``DataTypeMap``.
669662
670663
Returns:
671664
DataTypeMap which represents the PythonType, Arrow DataType, and
672665
SqlType Enum which this expression represents.
673666
"""
674-
return self.expr.types()
667+
return self.expr.types() # type: ignore
675668

676669
def python_value(self) -> Any:
677670
"""Extracts the Expr value into a PyObject.

0 commit comments

Comments
 (0)