apache / arrow

Apache Arrow is the universal columnar format and multi-language toolbox for fast data interchange and in-memory analytics
https://arrow.apache.org/
Apache License 2.0
14.55k stars 3.54k forks source link

[Python] When I import PyArrow and use Pyright linter CLI, it reports: Stub file not found for "pyarrow" #36113

Open joao-parana opened 1 year ago

joao-parana commented 1 year ago

Describe the usage question you have. Please include as many useful details as possible.

When I import PyArrow and use Pyright linter CLI, it reports: Stub file not found for "pyarrow"

from pyarrow import parquet as pq
# . . .
# some python code here
pyright main.py

show this:

Stub file not found for "pyarrow" (reportMissingTypeStubs)

By the way, pyright is a Type Checker for Python. See : `https://github.com/microsoft/pyright

Any suggestion to solve this?

Tanks.

Component(s)

Python

SChakravorti21 commented 1 year ago

Seconding this. In my experience, mypy is not able to type-check code that uses PyArrow, either.

gowtham-source commented 1 year ago

Solution 1 : Install PyArrow type stubs You can try installing the PyArrow type stubs separately using the following command:

pip install pyarrow-stubs

This package contains the necessary type annotations for PyArrow, allowing Pyright to understand the library's API and perform accurate type checking.

Solution 2 : Use an alternative linter If installing the PyArrow type stubs doesn't resolve the issue, consider using a different linter that supports PyArrow or provides more flexible type checking. Mypy and PyLint are popular alternatives that you can install and configure to check your code.

Solution 3 : Ignore the Pyright error If you are confident in the correctness of your PyArrow usage and want to continue using Pyright without type checking for PyArrow, you can configure Pyright to ignore the specific error related to the missing stub file. Create a pyrightconfig.json file in your project's root directory and add the following content:

{
  "reportMissingTypeStubs": "none"
}

This configuration will prevent Pyright from reporting the missing stub file error for "pyarrow".

Please note that the availability and compatibility of type stubs can vary across different libraries, and not all libraries may have dedicated stub files. If none of the above solutions work, consider reaching out to the PyArrow community or raising an issue on the Pyright GitHub repository for further assistance.

rmorshea commented 1 year ago

Duplicate of https://github.com/apache/arrow/issues/32609