Skip to content

fix: replace invalid tuple type annotations with typing.Tuple - #713

Merged
karel-rehor merged 1 commit into
influxdata:masterfrom
SukhmanH:fix/invalid-tuple-type-annotations
Aug 5, 2026
Merged

fix: replace invalid tuple type annotations with typing.Tuple#713
karel-rehor merged 1 commit into
influxdata:masterfrom
SukhmanH:fix/invalid-tuple-type-annotations

Conversation

@SukhmanH

@SukhmanH SukhmanH commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Closes #540

Proposed Changes

Briefly describe your proposed changes:

The batching callback signatures annotate conf as (str, str, str). A tuple of
types is not a valid type annotation, so any code copy-pasted from the README
fails type checking:

example.py:7: error: Syntax error in type annotation  [syntax]
example.py:7: note: Suggestion: Use Tuple[T1, ..., Tn] instead of (T1, ..., Tn)

This replaces the pattern with Tuple[str, str, str] in the 23 places it
appears:

  • influxdb_client/client/write_api.py — the _BatchItem.to_key_tuple() return
    annotation, which is the value actually passed to the callbacks
    (bucket, org, precision)
  • influxdb_client/client/util/multiprocessing_helper.py — the
    _success_callback / _error_callback / _retry_callback signatures
  • influxdb_client/client/influxdb_client.py and multiprocessing_helper.py
    docstring examples
  • examples/write_api_callbacks.py, examples/http_error_handling.py
  • tests/test_WriteApiBatching.py
  • README.md

typing.Tuple is used rather than the PEP 585 builtin tuple[...] because
setup.py still declares python_requires='>=3.7'. The copy-pasteable examples
also gained the matching from typing import Tuple import so they remain
runnable as-is, which was the original point of the issue.

This is annotation-only — no runtime behaviour changes. Verified:

  • mypy on the README snippet: 3 errors before, clean after
  • flake8 setup.py influxdb_client/ reports the same 2 pre-existing E721
    warnings in generated _sync/_async code as on master, and nothing new
  • pytest tests/test_WriteApiBatching.py — 24 passed

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • pytest tests completes successfully
  • Commit messages are conventional
  • Sign CLA (if not already signed)

@codecov-commenter

codecov-commenter commented Jul 25, 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.41%. Comparing base (97b0209) to head (38d8241).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #713   +/-   ##
=======================================
  Coverage   90.41%   90.41%           
=======================================
  Files          40       40           
  Lines        3546     3547    +1     
=======================================
+ Hits         3206     3207    +1     
  Misses        340      340           

☔ 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.

@bednar
bednar requested a review from karel-rehor August 3, 2026 04:19
The batching callback signatures used `(str, str, str)` as a type
annotation. A tuple of types is not a valid annotation, so mypy reports
"Syntax error in type annotation" on code copy-pasted from the README.

Replace with `Tuple[str, str, str]` in the callback signatures, the
`_BatchItem.to_key_tuple` return annotation, examples, tests and the
docs. `typing.Tuple` is used rather than the PEP 585 builtin `tuple`
because the package still supports Python 3.7.

Closes influxdata#540
@karel-rehor
karel-rehor force-pushed the fix/invalid-tuple-type-annotations branch from 55070e6 to 38d8241 Compare August 5, 2026 12:07

@karel-rehor karel-rehor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@SukhmanH

Thank you for your contribution!

All tests are stable.

N.B. in the CHANGELOG.md we need the link to the PR that resolves the issue not the link to the issue. I see this was not detected in previous PR merges. I'll fix this up in a separate PR before the release.

Looks good to me. 🚴 🏁

@karel-rehor
karel-rehor merged commit f54c45f into influxdata:master Aug 5, 2026
14 checks passed
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.

SyntaxError in examples

4 participants