1Password / connect-sdk-python

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

Add is_async switch to new_client_from_enviroment #89

Open mjpieters opened 1 year ago

mjpieters commented 1 year ago

This change makes it possible to use new_client_from_enviroment() and still select between async and sync clients based on the current codebase.

The change includes the type hints needed for type checkers to know what kind of object is returned in what circumstances; e.g.

# client: onepasswordconnectsdk.client.Client
client = new_client_from_environment(is_async=False)

# client: onepasswordconnectsdk.async_client.AsyncClient
async_client = new_client_from_environment(is_async=True)

This makes working with the library a lot easier in IDEs with type checker support as they now know what exact methods a client supports.

This fixes #84

mjpieters commented 11 months ago

Happy to drop this PR if / when #92 is merged.