Skip to content

flux_table.py Linting (Bug and FIX) #674

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

Closed
youarecode opened this issue Oct 6, 2024 · 4 comments · Fixed by #677
Closed

flux_table.py Linting (Bug and FIX) #674

youarecode opened this issue Oct 6, 2024 · 4 comments · Fixed by #677
Labels
bug Something isn't working
Milestone

Comments

@youarecode
Copy link
Contributor

Specifications

  • Client Version: 1.46.0
  • InfluxDB Version:
  • Platform:

Code sample to reproduce problem

TableList Typing is not working:

  • just write (no need to execute) this in vscode, it may lead to a static linting error
bucket='MyBucket'
measurement='MyMeasurement'
field='MyField'
query=f'''
        from(bucket: "{bucket}")
        |> range(start:0)
        |> filter(fn: (r) => r["_measurement"] == "{measurement}")
        |> filter(fn: (r) => r["_field"] == "{field}")
        |> last()
'''
client=InfluxDBClient(url, token, org)
query_api=client.query_api()
result=query_api.query(query)

MyValue=result[0].records[0].get_value() if result else False
MyTimestamp=result[0].records[0].get_time()  if result else False

Expected behavior

Linting to work for:

  • record field 'get_value()' or get_time()

Actual behavior

SOLUTION:

Add typing here:

# flux_table.py
class FluxTable(FluxStructure):
    def __init__(self) -> None:
        """Initialize defaults."""
        self.columns: List[FluxColumn] = []  #<<<<---- add this typing here
        self.records: List[FluxRecord] = []     #<<<<---- add this typing here

Additional info

Thank you in advance

@youarecode youarecode added the bug Something isn't working label Oct 6, 2024
@bednar
Copy link
Contributor

bednar commented Oct 7, 2024

@youarecode thanks for using our client.

Is this something you would be willing to help with? All PR is welcome and we will be happy to review your submission.

@youarecode
Copy link
Contributor Author

You are probably right, but to be honest, that line of code was my first contact with influxdb,

Even for simple code I know nothing about the system. :)

@bednar
Copy link
Contributor

bednar commented Oct 7, 2024

Your code suggestion is fine and correct 👍

SOLUTION:

Add typing here:

# flux_table.py
class FluxTable(FluxStructure):
    def __init__(self) -> None:
        """Initialize defaults."""
        self.columns: List[FluxColumn] = []  #<<<<---- add this typing here
        self.records: List[FluxRecord] = []     #<<<<---- add this typing here

Once you’ve submitted the PR, I’ll review it as soon as possible. If there are any further adjustments needed, I’ll provide feedback through the GitHub PR comments.

You’re on your way to becoming one of our contributors ;)

@youarecode
Copy link
Contributor Author

youarecode commented Oct 7, 2024 via email

youarecode added a commit to youarecode/influxdb-client-python that referenced this issue Oct 7, 2024
@bednar bednar added this to the 1.47.0 milestone Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants