influxdata / influxdata/influxdb-client-python

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

Đang mở
#694 0 bình luận 6 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
793
Fork
186
Merge trung bình
3 giờ 2 phút
Pull request đã merge (30 ngày)
1

Mô tả

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!

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách kiểm tra influxdb_client/__init__.py và marker py.typed của package, sau đó tái hiện import được ghi trong tài liệu `from influxdb_client import InfluxDBClient` bằng Pyright hoặc Pylance. Xác định các export công khai dự kiến và xác minh rằng import ở cấp cao nhất không còn tạo ra chẩn đoán về private import đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.