diff --git a/python/pyarrow/table.pxi b/python/pyarrow/table.pxi index 1abe4235c41..b712dce6c39 100644 --- a/python/pyarrow/table.pxi +++ b/python/pyarrow/table.pxi @@ -6292,6 +6292,8 @@ def concat_tables(tables, MemoryPool memory_pool=None, str promote_options="none promote_options : str, default none Accepts strings "none", "default" and "permissive". **kwargs : dict, optional + Additional arguments. The deprecated ``promote`` argument is accepted + for backward compatibility. Examples -------- @@ -6321,6 +6323,12 @@ def concat_tables(tables, MemoryPool memory_pool=None, str promote_options="none CConcatenateTablesOptions options = ( CConcatenateTablesOptions.Defaults()) + unexpected_kwargs = [key for key in kwargs if key != "promote"] + if unexpected_kwargs: + raise TypeError( + f"concat_tables() got an unexpected keyword argument " + f"'{unexpected_kwargs[0]}'") + if "promote" in kwargs: warnings.warn( "promote has been superseded by promote_options='default'.", diff --git a/python/pyarrow/tests/test_table.py b/python/pyarrow/tests/test_table.py index bf6e5773ddf..f4d219ef5a9 100644 --- a/python/pyarrow/tests/test_table.py +++ b/python/pyarrow/tests/test_table.py @@ -2013,6 +2013,15 @@ def test_concat_tables_invalid_option(): pa.concat_tables([t, t], promote_options="invalid") +def test_concat_tables_rejects_unknown_keyword_arguments(): + t = pa.Table.from_arrays([list(range(10))], names=('a',)) + + with pytest.raises( + TypeError, + match="unexpected keyword argument 'totally_bogus_kwarg'"): + pa.concat_tables([t, t], totally_bogus_kwarg=True) + + def test_concat_tables_none_table(): # ARROW-11997 with pytest.raises(AttributeError):