AlenkaF commented on PR #55264:
URL: https://github.com/apache/arrow/pull/55264#issuecomment-6658773241

   @tadeja @rok I have checked `table.pyi` and pushed the changes in commit 
(d9f0adb). Posting reasons for most of the changes here:
   
   `ChunkedArray`
   * `_name` is private, can be removed (@tadeja note, also made a diff in 
`array.pyi`)
   * `getitem` is cdef, stubs removed
   * `safe` in `cast` can be `None` if you specify `target_type` or `options`. 
In this case it will
     be turned into `True` (`CastOptions.safe(...)`). Maybe we should update 
the docstrings.
   * `arrays` in `chunked_array`: `NullableCollection` should be the same as 
`Collections` 
https://github.com/python/typeshed/blob/17cbf254205549ccdcf886fadf8c265e634ad596/stdlib/typing.pyi#L677-L681,
 I think this might be a leftover from when generics have been used.
   
   `RecordBatch`
   * Updated mapping in `from_pydict` to be in line with values in `asarray` 
method (array.pyi)
   * I suggest removing the use of `Generator[*, None, None]` and use 
`Iterator[*]` instead
   * Cython defines `list arrays` in `from_arrays()` so I corrected the type 
from `Iterable[Any]` to `list[Any]`. Similar for `struct_array` in 
`from_struct_array`
   * In `from_pandas` the reason for the change from `Sequence` to `Iterable` 
is because of the use of columns in `_resolve_columns_of_interest`.
   * In `equals` the parameter `other` is changed to `object` as in the Cython 
signature. If other is anything else than `RecordBatch` at runtime, the method 
returns `False`
   * Removing `table_to_blocks` as it is an internal helper. Similar to 
`string_to_tzinfo`, `tzinfo_to_string` and `ensure_metadata` which are not in 
the stubs currently. Later we should add them to the stubtest allowlist.
   
   `Table`
   * `from_arrays` column parameter should be `Sequence` instead of 
`Collections` as types without `__getitem__` error at runtime, added an 
example. Also changed `list` to `Iterable` so that tuple also works (which 
should also cover `NDArray[Any]`)
   * `column` in `add_column` takes `ChunkedArray` or anything array-like that 
chunked_array supports so I created an alias for the array-like chunked version 
(`ChunkedArrayConstructorInput`) and used that in `add_column` and `set_column`.
   * Found a bug in `record_batch` in the data parameter. Tuple is erroring at 
runtime (`pa.record_batch(([1, 2],), names=["a"])` gives `TypeError: Argument 
'arrays' has incorrect type (expected list, got tuple)`). I will create a 
separate issue for this and will add the link to it in this comment later. I 
have changed the `Collection` in ste stubs to `list[Any]` to be equal to 
`RecordBatch.from_array()` as that is what is used at runtime. I also changed 
`Mapping` to `dict` as it is also checked directly via `isinstance(data, dict)` 
in the code.
   
   
   Note: I am not sure about `Mappings` in `from_pydict` and `from_pylist`, 
will have a separate look at this tomorrow.
   
   @tadeja I also created `MapsAsPydicts` type alias and added a use of that in 
array.pyi. Hope that is OK.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to