Skip to content

Commit 00d2505

Browse files
authored
Clearer guidance for unused kwargs (Azure#23149)
1 parent a1deaf3 commit 00d2505

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,12 @@ implement additional methods. The [`azure-identity`][identity_github] package ha
560560
implementations that can be used for reference. For example, the [`InteractiveCredential`][interactive_cred] is used as
561561
a base class for multiple credentials and uses `claims` and `tenant_id` in token requests.
562562

563+
If a `TokenCredential` implementation doesn't have a use for a keyword argument in a given scenario, the unused
564+
keyword argument should be removed from `kwargs` before getting passed elsewhere. The documentation for the
565+
implementation should mention that this keyword argument will not be used when making token requests, as well as any
566+
potential consequences of this. For example, if a `TokenCredential` implementation doesn't use `tenant_id`, it should
567+
document that fetched tokens may not authorize requests made to the specified tenant.
568+
563569
There is also an async protocol -- the `AsyncTokenCredential` protocol -- that specifies a class with an aysnc
564570
`get_token` method with the same arguments. An `AsyncTokenCredential` implementation additionally needs to be a context
565571
manager, with `__aenter__`, `__aexit__`, and `close` methods.

0 commit comments

Comments
 (0)