diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 6ba0c2c9..f1ad4bda 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -47,5 +47,5 @@ jobs: - name: Lint with Ruff run: | pip install ruff - ruff check --output-format=github --exclude=src/onepassword/lib/ . + ruff check --output-format=github --exclude=src/onepassword/lib/,example/ . continue-on-error: true diff --git a/example/example.py b/example/example.py index 4e1c6431..bb25116e 100644 --- a/example/example.py +++ b/example/example.py @@ -2,7 +2,6 @@ import os from onepassword import * - async def main(): # Gets your service account token from the OP_SERVICE_ACCOUNT_TOKEN environment variable. token = os.getenv("OP_SERVICE_ACCOUNT_TOKEN") @@ -24,7 +23,7 @@ async def main(): id="", title="MyName", category="Login", - vault_id="vault_id", + vault_id="q73bqltug6xoegr3wkk2zkenoq", fields=[ ItemField( id="username", @@ -48,7 +47,7 @@ async def main(): print(dict(created_item)) # Retrieve an item from your vault. - item = await client.items.get("vault_id", created_item.id) + item = await client.items.get(created_item.vault_id, created_item.id) print(dict(item)) @@ -59,7 +58,7 @@ async def main(): print(dict(updated_item)) # Delete a item from your vault. - await client.items.delete("vault_id", updated_item.id) + await client.items.delete(created_item.vault_id, updated_item.id) if __name__ == "__main__": diff --git a/src/onepassword/__init__.py b/src/onepassword/__init__.py index ccc0f59f..47d5167f 100644 --- a/src/onepassword/__init__.py +++ b/src/onepassword/__init__.py @@ -5,6 +5,9 @@ from .secrets import Secrets from .items import Items +import sys +import inspect +import typing __all__ = [ "Client", @@ -14,5 +17,7 @@ "DEFAULT_INTEGRATION_VERSION", ] -if hasattr(types, "__all__"): - __all__ += types.__all__ +for name, obj in inspect.getmembers(sys.modules["onepassword.types"]): + # Add all classes and instances of typing.Literal defined in types.py. + if (inspect.isclass(obj) and inspect.getmodule(obj) == sys.modules["onepassword.types"]) or type(eval(name)) == typing._LiteralGenericAlias: + __all__.append(name)