Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError in examples #540

Open
hterik opened this issue Dec 20, 2022 · 3 comments
Open

SyntaxError in examples #540

hterik opened this issue Dec 20, 2022 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@hterik
Copy link

hterik commented Dec 20, 2022

Specifications

  • Client Version: 1.35
  • python version 3.10.8
  • mypy version 0.991

Code sample to reproduce problem

Code example from README.rst

class BatchingCallback(object):

    def success(self, conf: (str, str, str), data: str):
        print(f"Written batch: {conf}, data: {data}")

Expected behavior

Code from Readme can be copy-pasted into source file and not generate syntax errors from either python nor mypy.

Actual behavior

Running mypy gives error:

example.py: note: In member "success" of class "BatchingCallback":
example.py:75:27: error: Syntax error in type annotation  [syntax]
example.py:75:27: note: Suggestion: Use Tuple[T1, ..., Tn] instead of (T1, ..., Tn)

Additional info

Using the suggestion from mypy error message should be sufficent.

(Would be great if tuple alias could be used instead of typing.Tuple to save on import verbosity, but that requires 3.9+, this library is currently targeting 3.7+.)

@hterik hterik added the bug Something isn't working label Dec 20, 2022
@bednar
Copy link
Contributor

bednar commented Dec 20, 2022

Hi @hterik,

thanks for using our client.

I am not able to simulate your SyntaxError:

from influxdb_client import InfluxDBClient
from influxdb_client.client.exceptions import InfluxDBError


class BatchingCallback(object):

    def success(self, conf: (str, str, str), data: str):
        print(f"Written batch: {conf}, data: {data}")

    def error(self, conf: (str, str, str), data: str, exception: InfluxDBError):
        print(f"Cannot write batch: {conf}, data: {data} due: {exception}")

    def retry(self, conf: (str, str, str), data: str, exception: InfluxDBError):
        print(f"Retryable error occurs for batch: {conf}, data: {data} retry: {exception}")


with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") as client:
    callback = BatchingCallback()
    with client.write_api(success_callback=callback.success,
                          error_callback=callback.error,
                          retry_callback=callback.retry) as write_api:
        pass

The python examples/example.py pass without error.

python --version             
Python 3.9.15

Can you share your python version or step-by-step guide to simulate the SyntaxError?

Regards

@bednar bednar added question Further information is requested and removed bug Something isn't working labels Dec 20, 2022
@hterik
Copy link
Author

hterik commented Dec 20, 2022

Try mypy examples/example.py

@bednar
Copy link
Contributor

bednar commented Dec 20, 2022

@hterik thanks for this suggestion. There is a lot of code in our source base which is not complain with http://mypy-lang.org.

Is this something you might be willing to help with?

@bednar bednar added enhancement New feature or request good first issue Good for newcomers and removed question Further information is requested labels Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants