Skip to content

Commit 13dcdd4

Browse files
timsaucerclaude
andcommitted
refactor: type physical_optimizer_rules with an Exportable Protocol
Replace the `list[Any]` hint on the SessionContext `physical_optimizer_rules` argument with a `PhysicalOptimizerRuleExportable` Protocol, matching the existing `TableProviderExportable` / `*Exportable` pattern used for other FFI-capsule objects. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent daa8da9 commit 13dcdd4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

python/datafusion/context.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ class TableProviderExportable(Protocol):
130130
def __datafusion_table_provider__(self, session: Any) -> object: ... # noqa: D105
131131

132132

133+
class PhysicalOptimizerRuleExportable(Protocol):
134+
"""Type hint for object that has __datafusion_physical_optimizer_rule__ PyCapsule.
135+
136+
The capsule wraps an ``FFI_PhysicalOptimizerRule``, typically produced by a
137+
separate compiled extension.
138+
"""
139+
140+
def __datafusion_physical_optimizer_rule__(self) -> object: ... # noqa: D105
141+
142+
133143
class SessionConfig:
134144
"""Session configuration options."""
135145

@@ -524,7 +534,7 @@ def __init__(
524534
self,
525535
config: SessionConfig | None = None,
526536
runtime: RuntimeEnvBuilder | None = None,
527-
physical_optimizer_rules: list[Any] | None = None,
537+
physical_optimizer_rules: list[PhysicalOptimizerRuleExportable] | None = None,
528538
) -> None:
529539
"""Main interface for executing queries with DataFusion.
530540

0 commit comments

Comments
 (0)