1Password / connect-sdk-python

Python SDK for 1Password Connect
https://developer.1password.com/docs/connect
MIT License
200 stars 30 forks source link

Cleaner client constructors #92

Open melwil opened 10 months ago

melwil commented 10 months ago

This PR aims to improve the constructor for new clients.

I've removed all code related to AsyncClient from client.py, and allowed you to directly make AsyncClient. This does mean it's a breaking change, but one that is easily caught by tests or type checkers.

There are a couple of reasons for this:

Finally, I will concede that it's not the greatest idea to repeat the code for getting the env vars and validating them in both constructors, it could be moved to some sort of utility function. I can do that if desireable, but in this case it's not a great chance for reusability.

codecov-commenter commented 10 months ago

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (8b31f93) 77.08% compared to head (708a6cc) 76.83%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #92 +/- ## ========================================== - Coverage 77.08% 76.83% -0.25% ========================================== Files 27 27 Lines 1933 1943 +10 ========================================== + Hits 1490 1493 +3 - Misses 443 450 +7 ``` | [Files](https://app.codecov.io/gh/1Password/connect-sdk-python/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [src/onepasswordconnectsdk/\_\_init\_\_.py](https://app.codecov.io/gh/1Password/connect-sdk-python/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL29uZXBhc3N3b3JkY29ubmVjdHNkay9fX2luaXRfXy5weQ==) | `100.00% <100.00%> (ø)` | | | [src/tests/test\_client\_items.py](https://app.codecov.io/gh/1Password/connect-sdk-python/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3Rlc3RzL3Rlc3RfY2xpZW50X2l0ZW1zLnB5) | `100.00% <100.00%> (ø)` | | | [src/tests/test\_client\_vaults.py](https://app.codecov.io/gh/1Password/connect-sdk-python/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3Rlc3RzL3Rlc3RfY2xpZW50X3ZhdWx0cy5weQ==) | `100.00% <100.00%> (ø)` | | | [src/onepasswordconnectsdk/client.py](https://app.codecov.io/gh/1Password/connect-sdk-python/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL29uZXBhc3N3b3JkY29ubmVjdHNkay9jbGllbnQucHk=) | `62.87% <66.66%> (-0.50%)` | :arrow_down: | | [src/onepasswordconnectsdk/async\_client.py](https://app.codecov.io/gh/1Password/connect-sdk-python/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL29uZXBhc3N3b3JkY29ubmVjdHNkay9hc3luY19jbGllbnQucHk=) | `63.09% <38.46%> (-2.07%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

volodymyrZotov commented 8 months ago

@melwil Agree on the changes you've introduced, that will make it work well for type checkers. However, it will be a breaching change, as in case somebody's already used the client with is_async parameter, this new version will break for them. But there is no problem with that, we can release v2.0.0 an mention this change in the release notes.

Could you resolve the conflict, please?