Skip to content
Merged
2 changes: 1 addition & 1 deletion python/pyarrow/_compute.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2686,7 +2686,7 @@ cdef class Expression(_Weakrefable):
cdef inline CExpression unwrap(self):
return self.expr

def equals(self, Expression other):
def equals(self, Expression other not None):
"""
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/_dataset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4052,7 +4052,7 @@ cdef class Scanner(_Weakrefable):
return reader


def get_partition_keys(Expression partition_expression):
def get_partition_keys(Expression partition_expression not None):
"""
Extract partition keys (equality constraints between a field and a scalar)
from an expression as a dict mapping the field's name to its value.
Expand Down
3 changes: 3 additions & 0 deletions python/pyarrow/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4371,6 +4371,9 @@ def test_expression_construction():
with pytest.raises(TypeError):
field.isin(1)

with pytest.raises(TypeError, match="Argument 'other' has incorrect type"):
field.equals(None)

with pytest.raises(pa.ArrowInvalid):
field != object()

Expand Down
3 changes: 3 additions & 0 deletions python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,9 @@ def test_partition_keys():
null = ds.field('a').is_null()
assert ds.get_partition_keys(null) == {'a': None}

with pytest.raises(TypeError, match="Argument 'partition_expression'"):
ds.get_partition_keys(None)


@pytest.mark.parquet
def test_parquet_read_options():
Expand Down
Loading