This is an automated email from the ASF dual-hosted git repository.

jonkeane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ffc10a43b ARROW-14632: [Python] Make write_dataset arguments 
keyword-only
2ffc10a43b is described below

commit 2ffc10a43b2b9a397bfeba993993172082f9722b
Author: Austin Dickey <[email protected]>
AuthorDate: Wed Jun 1 17:22:17 2022 -0500

    ARROW-14632: [Python] Make write_dataset arguments keyword-only
    
    As a best practice, most of the optional configuration arguments in 
`write_dataset()` should be keyword-only. This PR enforces that.
    
    Closes #13289 from austin3dickey/ARROW-14632
    
    Authored-by: Austin Dickey <[email protected]>
    Signed-off-by: Jonathan Keane <[email protected]>
---
 python/pyarrow/dataset.py            | 2 +-
 python/pyarrow/tests/test_dataset.py | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/python/pyarrow/dataset.py b/python/pyarrow/dataset.py
index 6c1b8db5a6..8ef3e2f7aa 100644
--- a/python/pyarrow/dataset.py
+++ b/python/pyarrow/dataset.py
@@ -801,7 +801,7 @@ def _ensure_write_partitioning(part, schema, flavor):
     return part
 
 
-def write_dataset(data, base_dir, basename_template=None, format=None,
+def write_dataset(data, base_dir, *, basename_template=None, format=None,
                   partitioning=None, partitioning_flavor=None, schema=None,
                   filesystem=None, file_options=None, use_threads=True,
                   max_partitions=None, max_open_files=None,
diff --git a/python/pyarrow/tests/test_dataset.py 
b/python/pyarrow/tests/test_dataset.py
index 0be01d2336..d2210c4b6c 100644
--- a/python/pyarrow/tests/test_dataset.py
+++ b/python/pyarrow/tests/test_dataset.py
@@ -1796,6 +1796,12 @@ def 
test_dictionary_partitioning_outer_nulls_raises(tempdir):
         ds.write_dataset(table, tempdir, format='ipc', partitioning=part)
 
 
+def test_positional_keywords_raises(tempdir):
+    table = pa.table({'a': ['x', 'y', None], 'b': ['x', 'y', 'z']})
+    with pytest.raises(TypeError):
+        ds.write_dataset(table, tempdir, "basename-{i}.arrow")
+
+
 @pytest.mark.parquet
 @pytest.mark.pandas
 def test_read_partition_keys_only(tempdir):

Reply via email to