fix: replace invalid tuple type annotations with typing.Tuple - #713
Open
SukhmanH wants to merge 1 commit into
Open
fix: replace invalid tuple type annotations with typing.Tuple#713SukhmanH wants to merge 1 commit into
SukhmanH wants to merge 1 commit into
Conversation
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
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #713 +/- ##
=======================================
Coverage 90.38% 90.38%
=======================================
Files 40 40
Lines 3546 3547 +1
=======================================
+ Hits 3205 3206 +1
Misses 341 341 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #540
Proposed Changes
Briefly describe your proposed changes:
The batching callback signatures annotate
confas(str, str, str). A tuple oftypes is not a valid type annotation, so any code copy-pasted from the README
fails type checking:
This replaces the pattern with
Tuple[str, str, str]in the 23 places itappears:
influxdb_client/client/write_api.py— the_BatchItem.to_key_tuple()returnannotation, 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_callbacksignaturesinfluxdb_client/client/influxdb_client.pyandmultiprocessing_helper.pydocstring examples
examples/write_api_callbacks.py,examples/http_error_handling.pytests/test_WriteApiBatching.pyREADME.mdtyping.Tupleis used rather than the PEP 585 builtintuple[...]becausesetup.pystill declarespython_requires='>=3.7'. The copy-pasteable examplesalso gained the matching
from typing import Tupleimport so they remainrunnable as-is, which was the original point of the issue.
This is annotation-only — no runtime behaviour changes. Verified:
mypyon the README snippet: 3 errors before, clean afterflake8 setup.py influxdb_client/reports the same 2 pre-existing E721warnings in generated
_sync/_asynccode as onmaster, and nothing newpytest tests/test_WriteApiBatching.py— 24 passedChecklist
pytest testscompletes successfully