influxdata / influxdata/influxdb-client-python

Public symbols not properly exported with `py.typed` present — triggers Pylance/Pyright errors

未关闭
#694 0 条评论 6 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
793
派生
186
平均合并
3 小时 2 分钟
30 天内合并 PR
1

描述

Hi team,

Thanks for maintaining this package — it's a great tool for working with InfluxDB.

I'm opening this issue to report a problem that affects type checkers and IDEs (like Pyright, Pylance, and mypy) due to the presence of the `py.typed` file in the `influxdb-client-python` package.

Since the package declares itself as typed (via `py.typed`, per [[PEP 561](https://peps.python.org/pep-0561/)](https://peps.python.org/pep-0561/)), tools like **Pyright** and **Pylance** apply stricter rules around public API exposure. Specifically, **public symbols must be explicitly exported** using either:

* a `__all__` list in `__init__.py`, or
* `.pyi` stub files.

Currently, this is not the case for the main client class. When importing `InfluxDBClient` from the top-level module as documented:

```python
from influxdb_client import InfluxDBClient
```

Pylance (and Pyright) raises the following error:

```
"InfluxDBClient" is not exported from module "influxdb_client"
Import from "influxdb_client.client.influxdb_client" instead
Pylance: reportPrivateImportUsage
```

This is confusing to users and suggests that the public API is not properly defined.

### Suggested solutions

To resolve this and ensure compatibility with type checkers, here are a few possible approaches:

1. **Add `__all__` to `influxdb_client/__init__.py`** to explicitly define the intended public interface.
2. **Provide proper `.pyi` stub files** that describe the public API.
3. If full typing support is not maintained, **consider removing the `py.typed` file** to avoid stricter validation.

Improving this would help developers relying on static analysis and IDE support, and reduce confusion about which imports are officially supported.

Thanks again for your work and for considering this issue!

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先检查 influxdb_client/__init__.py 和 package 的 py.typed 标记,然后使用 Pyright 或 Pylance 重现文档中的 `from influxdb_client import InfluxDBClient` 导入。确定预期的公共导出,并验证顶层导入不再产生所报告的私有导入诊断。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。