Skip to content

fix: explicitly re-export public client types - #722

Open
ac1982 wants to merge 2 commits into
influxdata:masterfrom
ac1982:fix/explicit-public-exports
Open

ac1982 wants to merge 2 commits into
influxdata:masterfrom
ac1982:fix/explicit-public-exports

Conversation

@ac1982

@ac1982 ac1982 commented Oct 21, 2026

Copy link
Copy Markdown

Closes #694.

Proposed Changes

Documented imports such as from influxdb_client import InfluxDBClient work at runtime but produce private-import errors in Pyright/Pylance and strict mypy because the typed package does not explicitly re-export them.

Use same-name import aliases for the existing public bindings in influxdb_client/__init__.py. This keeps runtime names and import behavior intact without adding a duplicate __all__ list or removing py.typed. Add a pytest regression that runs a representative consumer through strict mypy, with mypy included only in the test extra.

This replaces influxdata/influxdb-clients-apigen#84, following the request to fix the client directly.

Validation on Python 3.12/Linux ARM64:

  • Installed baseline and patched packages: Pyright 1.1.414 reports seven reportPrivateImportUsage errors before and zero after; mypy 2.4.0 reports seven explicit-export errors before and zero after. The new pytest regression fails before and passes after.
  • Selected offline tests: 128 passed, 2 subtests passed; the live-server test_write_context_manager case was deselected. The full integration suite was not run because no InfluxDB service was started.
  • Changed Python files pass flake8. Whole-package lint reports the same two existing E721 diagnostics on baseline and patch in _async/api_client.py and _sync/api_client.py.
  • Normalizing the redundant aliases yields an AST identical to the original package initializer. Other Python versions and operating systems were not tested locally.

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable against current master
  • A test has been added
  • pytest tests completes successfully — full integration suite not run; focused results above
  • Commit message is conventional
  • Sign CLA (not represented as signed here)

AI assistance: OpenAI Codex investigated, implemented, and validated this follow-up.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes preserve runtime behavior, add focused regression coverage, and leave only an optional docstring correction.

1 open issue
What changed in this PR

Fixes #694 by explicitly exporting existing top-level client symbols for type checkers without changing runtime imports.

Changes:

  • Adds same-name aliases to public imports.
  • Adds runtime and mypy regression coverage, with mypy in the test extra.
  • Documents the fix in the changelog.
File Description
tests/​typing/​public_exports.py Provides a representative consumer fixture.
tests/​test_PublicExports.py Checks runtime imports and explicit exports with mypy.
setup.py Adds mypy as a test dependency.
influxdb_client/​__init__.py Explicitly re-exports existing public symbols.
CHANGELOG.md Records the type-checker compatibility fix.

Review effort: Balanced

Comment thread tests/typing/public_exports.py Outdated
@codecov-commenter

codecov-commenter commented Oct 21, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.39%. Comparing base (ef60f89) to head (57f947d).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #722      +/-   ##
==========================================
- Coverage   90.49%   90.39%   -0.11%     
==========================================
  Files          40       41       +1     
  Lines        3568     3580      +12     
==========================================
+ Hits         3229     3236       +7     
- Misses        339      344       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Fix docstring to correct the language and formatting.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants