Copilot commented on code in PR #48622:
URL: https://github.com/apache/arrow/pull/48622#discussion_r3409864851
##########
python/pyarrow/fs.py:
##########
@@ -111,7 +111,7 @@ def _ensure_filesystem(filesystem, *, use_mmap=False):
else:
# handle fsspec-compatible filesystems
try:
- import fsspec
+ import fsspec # type: ignore[import-untyped]
Review Comment:
The `# type: ignore` here only suppresses the `import-untyped` error code.
Since `fsspec` is an optional dependency (ImportError is handled), type
checkers can also emit `import-not-found` when it isn't installed in the
type-checking environment. Consider ignoring both codes to keep the annotation
robust across environments.
##########
python/pyarrow-stubs/pyarrow/_stubs_typing.pyi:
##########
@@ -0,0 +1,138 @@
+# 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.
+
+import datetime as dt
+
+from _typeshed import (
+ SupportsDunderGE,
+ SupportsDunderGT,
+ SupportsDunderLE,
+ SupportsDunderLT,
+)
+from collections.abc import Collection, Container, Iterator, Sequence, Sized
+from decimal import Decimal
+from typing import Any, Literal, Protocol, TypeAlias, TypeVar
+from typing_extensions import TypeAliasType
+
+import numpy as np
+
+from numpy.typing import NDArray
+
+from pyarrow import lib
+from pyarrow.lib import ChunkedArray
Review Comment:
In stubs, `from pyarrow import lib` will currently type `lib` as `Any`
because `pyarrow/__init__.pyi` defines `__getattr__` returning `Any` and
doesn't declare a `lib` attribute. Import the submodule directly so references
like `lib.Int8Type` retain their (eventual) stubbed types instead of degrading
to `Any`.
##########
python/pyarrow-stubs/pyarrow/io.pyi:
##########
@@ -0,0 +1,25 @@
+# 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.
+
+# Placeholder stub - complete annotations in future PR.
+# At runtime, these symbols are provided by the pyarrow.lib C extension.
+
+from typing import Any
+
+class Buffer: ...
+
+def __getattr__(name: str) -> Any: ...
Review Comment:
This stub introduces a `pyarrow.io` submodule, but the Python build only
compiles Cython extensions for `pyarrow.lib`, `pyarrow._compute`,
`pyarrow._csv`, `pyarrow._feather`, `pyarrow._fs`, `pyarrow._json`, etc. (no
`io` extension module). If `pyarrow.io` is not importable at runtime, providing
a stub module for it will make type checkers accept imports that fail at
runtime. Consider either adding a real `pyarrow/io.py` wrapper module
(re-exporting from `pyarrow.lib`) or removing this stub and re-exporting the
relevant names from the actual modules (`pyarrow/__init__.pyi` /
`pyarrow/lib.pyi`).
##########
python/pyarrow-stubs/pyarrow/scalar.pyi:
##########
@@ -0,0 +1,25 @@
+# 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.
+
+# Placeholder stub - complete annotations in future PR.
+# At runtime, these symbols are provided by the pyarrow.lib C extension.
+
+from typing import Any
+
+class ExtensionScalar: ...
+
+def __getattr__(name: str) -> Any: ...
Review Comment:
This stub introduces a `pyarrow.scalar` submodule, but `scalar` appears to
be provided as a symbol from the `pyarrow.lib` extension (and re-exported from
`pyarrow/__init__.py`), not as an importable `pyarrow.scalar` module. If
`import pyarrow.scalar` is not valid at runtime, this stub module will let type
checkers accept imports that will fail when executed. Consider adding a real
`pyarrow/scalar.py` wrapper module (re-exporting from `pyarrow.lib`) or
removing this stub module and exposing the relevant names via
`pyarrow/__init__.pyi` / `pyarrow/lib.pyi`.
--
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]