Skip to content

Commit a14b495

Browse files
author
Raphael Krupinski
committed
✨ Add kwargs to lapidary_authenticate method, complain on duplicate arguments.
1 parent 5cd06dc commit a14b495

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/lapidary/runtime/client_base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,19 @@ def _resolve_auth(self, fn: Callable, security: Optional[Iterable[SecurityRequir
9797
else:
9898
return None
9999

100-
def lapidary_authenticate(self, *auths: NamedAuth) -> None:
101-
self._auth.update(auths)
100+
def lapidary_authenticate(self, *auth_args: NamedAuth, **auth_kwargs: httpx.Auth) -> None:
101+
"""Register named Auth instances for future use with methods that require authentication."""
102+
if auth_args:
103+
# make python complain about duplicate names
104+
self.lapidary_authenticate(**dict(auth_args), **auth_kwargs)
105+
106+
self._auth.update(auth_kwargs)
102107
self._auth_cache.clear()
103108

104109
def lapidary_deauthenticate(self, *sec_names: str) -> None:
110+
"""Remove reference to a given Auth instance.
111+
Calling with no parameters removes all references"""
112+
105113
if sec_names:
106114
for sec_name in sec_names:
107115
del self._auth[sec_name]

0 commit comments

Comments
 (0)