Skip to content

improve coverage for pyarrow.struct typehint #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2024
Merged

Conversation

ben-freist
Copy link
Contributor

Hey,
I ran into a mypy error and would like to fix it upstream.
This is from the docstring of pyarrow.struct.

import pyarrow as pa
from typing import List, Tuple

fields: List[Tuple[str, pa.DataType]] = [
    ("f1", pa.int32()),
    ("f2", pa.string()),
]
struct_type = pa.struct(fields)

To make the last line pass mypy Iterable[Tuple[str, DataType]] needs to be added to the stub.

The actual implementation is even more permissive, is that needed? I.e. Iterable[Tuple[x]] works as long as you can feed x into pyarrow.field.
(https://github.com/apache/arrow/blob/f9a6edac9f175de3ad993887470dd1dff4f151c1/python/pyarrow/types.pxi#L5195)

@zen-xu zen-xu enabled auto-merge (squash) December 14, 2024 08:45
@zen-xu zen-xu merged commit 1432d63 into zen-xu:main Dec 14, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants