AlenkaF commented on code in PR #55264: URL: https://github.com/apache/arrow/pull/55264#discussion_r4492827109
########## python/pyarrow-stubs/tests/test_table.py: ########## @@ -0,0 +1,152 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# mypy: warn-unused-ignores + +from types import MappingProxyType + +import pytest + +import pyarrow.lib as lib + +from _check import TYPE_CHECKING_INVALID_USAGE, assert_type, check + + +def test_table() -> None: + table = lib.table({"a": [1, 2], "b": ["x", "y"]}) + check(assert_type(table, lib.Table), lib.Table) + check(assert_type(table.num_rows, int), int) + check(assert_type(table.num_columns, int), int) + check(assert_type(table.shape, tuple[int, int]), tuple) + check(assert_type(table.column_names, list[str]), list) + check(assert_type(table.schema, lib.Schema), lib.Schema) + check(assert_type(table.field("a"), lib.Field), lib.Field) + + # Columns aren't typed per tabular class, so Table and RecordBatch both + # return the union here. + check(assert_type(table.column("a"), lib.Array | lib.ChunkedArray), + lib.ChunkedArray) + check(assert_type(table["a"], lib.Array | lib.ChunkedArray | lib.Table), Review Comment: We would need overloads to make this useful if I am not mistaken? (split between str returning a column and slice returning a table?) -- 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]
