Pyright does not recognize pandera.polars exports: reportPrivateImportUsage
Describe the bug
Pyright throws reportPrivateImportUsage errors on basically everything imported from pandera.polars.
- [x] I have checked that this issue has not already been reported.
- [x] I have confirmed this bug exists on the latest version of pandera.
- [x] (optional) I have confirmed this bug exists on the main branch of pandera.
Simply running pyright by hand on a minimal example like this will show the problem:
#!/usr/bin/python3
# privates.py
import pandera.polars as pa
class SomeSchema(pa.DataFrameModel):
height: float
horizontal_accuracy: float
config_id: str = pa.Field(nullable=True)
➜ pyright privates.py
/SNIP/privates.py
/SNIP/privates.py:6:21 - error: "DataFrameModel" is not exported from module "pandera.polars" (reportPrivateImportUsage)
/SNIP/privates.py:9:25 - error: "Field" is not exported from module "pandera.polars" (reportPrivateImportUsage)
2 errors, 0 warnings, 0 informations
Expected behavior
Running pyright (either by hand or indirectly as an LSP in an editor) should not give any errors. More importantly I don't expect little red squiggly lines on literally every import from pandera.polars.
Context
I'm currently on pandera version 0.20.1 and pyright version 1.1.368.
To me it looks like Pylance papers over these issues or swallows the error even though it's using pyright under the hood. The pyright folk are really pretty clear that this is as designed and it ought to be fixed in the libraries. See this issue in pyright for example.
If you agree this is an issue and should be fixed in pandera I can probably find the time to make a PR!
Hi @RmStorm, this is probably because the pandera.polars module doesn't define __all__... can you try adding it e.g. see here and see if the pyright error goes away?
I have this same issue, using the built in basic level typing checking provided by pyright/pylance in vscode. pandera 0.20.3 and polars 1.5.0. shows when just testing the examples of the docs
Adding that __all__ ... to the polars.py in the pandera package worked but still getting some other typing errors as seen