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

fix: add support for "with .. as .." statement for cleaner exception … #218

Merged
merged 3 commits into from
Apr 13, 2021

Conversation

rhajek
Copy link
Contributor

@rhajek rhajek commented Mar 26, 2021

Closes #190

This PR adds __enter__ and __exit__ methods to support with .. as ..: statement.

        with InfluxDBClient.from_env_properties(self.debug) as client:
            with client.write_api(write_options=WriteOptions(write_type=WriteType.batching)) as write_api:
              write_api.write(bucket="my-bucket",
                                record=Point("h2o_feet")
                                .tag("location", "coyote_creek")
                                .field("level water_level", 5.0))

@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #218 (591bd60) into master (d465dda) will increase coverage by 0.23%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
+ Coverage   90.75%   90.99%   +0.23%     
==========================================
  Files          26       26              
  Lines        2012     2020       +8     
==========================================
+ Hits         1826     1838      +12     
+ Misses        186      182       -4     
Impacted Files Coverage Δ
influxdb_client/client/influxdb_client.py 99.29% <100.00%> (+0.02%) ⬆️
influxdb_client/client/write_api.py 99.05% <100.00%> (+1.46%) ⬆️
influxdb_client/client/flux_table.py 88.88% <0.00%> (+2.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d465dda...591bd60. Read the comment docs.

@bednar bednar self-requested a review March 29, 2021 12:03
Copy link
Contributor

@bednar bednar left a comment

Choose a reason for hiding this comment

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

Could you please also update README.rst and sources in /example dir?

@rhajek rhajek force-pushed the fix/context-manager branch from 2123f70 to 7d22027 Compare April 13, 2021 12:19
@rhajek rhajek requested a review from bednar April 13, 2021 13:23
@bednar bednar merged commit 4792fd5 into master Apr 13, 2021
@bednar bednar deleted the fix/context-manager branch April 13, 2021 13:28
@bednar bednar added this to the 1.17.0 milestone Apr 13, 2021
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.

Documentation unclear on proper extended usage of WriteApi client
2 participants