Skip to content

Commit

Permalink
fix: add casts and add suppression to make pyright happy
Browse files Browse the repository at this point in the history
This commit fixes some problems found by `pyright`:
* In the DuckDB test, a `bytes` parameter is wrongly annotated as `str`
  in the stub files of that Python module. We silence that false
  positive with a suppression.
* In the test for converting MLIR ops to plans, we use some op-specific
  members on an object whose most narrow known type is `MlirOperation`,
  so the commit adds a `cast` to make the `typing` information more
  precise.
  • Loading branch information
ingomueller-net committed Dec 9, 2024
1 parent cd67237 commit 7c3a473
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/python/dialects/substrait/e2e_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def testNamedTable():
pb_plan = ss.to_binpb(plan.operation).encode()

# Execute in duckdb and print result.
query_result = con.from_substrait(proto=pb_plan)
query_result = con.from_substrait(proto=pb_plan) # type: ignore

print(query_result.to_arrow_table())
# CHECK-NEXT: pyarrow.Table
Expand Down
7 changes: 4 additions & 3 deletions test/python/dialects/substrait/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# RUN: %PYTHON %s 2>&1 | FileCheck %s

import json
from typing import cast

from substrait_mlir.dialects import substrait as ss, arith
from substrait_mlir.ir import Context, Location
Expand Down Expand Up @@ -42,7 +43,7 @@ def testJsonFormat():
print(json_plan)
# CHECK: {"version":{"minorNumber":42,"patchNumber":1}}

plan_op = plan_module.body.operations[0]
plan_op = cast(ss.PlanOp, plan_module.body.operations[0])
print(plan_op.to_json())
# CHECK: {"version":{"minorNumber":42,"patchNumber":1}}

Expand All @@ -68,7 +69,7 @@ def testTextPB():
# CHECK-NEXT: minor_number: 42
# CHECK-NEXT: patch_number: 1

plan_op = plan_module.body.operations[0]
plan_op = cast(ss.PlanOp, plan_module.body.operations[0])
print(plan_op.to_textpb())
# CHECK: version {

Expand All @@ -86,7 +87,7 @@ def testBinPB():
print(bin_plan)
# CHECK: 2

plan_op = plan_module.body.operations[0]
plan_op = cast(ss.PlanOp, plan_module.body.operations[0])
print(plan_op.to_binpb())
# CHECK: 2

Expand Down

0 comments on commit 7c3a473

Please sign in to comment.