diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-03 12:29:39 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-03 12:31:07 -0700 |
commit | 10a2374051568edf3d872988e730328d899a0fdd (patch) | |
tree | 795be5e149a021f84bc4305c1811e63cc86f7aa1 /python/fatcat_tools/api_auth.py | |
parent | cfab1ddcd8a05b62ecc16763d18a6ecee8fa234f (diff) | |
download | fatcat-10a2374051568edf3d872988e730328d899a0fdd.tar.gz fatcat-10a2374051568edf3d872988e730328d899a0fdd.zip |
typing: first batch of python bulk type annotations
While these changes are more delicate than simple lint changes, this
specific batch of edits and annotations was *relatively* simple, and
resulted in few code changes other than function signature additions.
Diffstat (limited to 'python/fatcat_tools/api_auth.py')
-rw-r--r-- | python/fatcat_tools/api_auth.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/python/fatcat_tools/api_auth.py b/python/fatcat_tools/api_auth.py index d8f0c46d..5eba583e 100644 --- a/python/fatcat_tools/api_auth.py +++ b/python/fatcat_tools/api_auth.py @@ -1,27 +1,28 @@ import os import sys +from typing import Optional -import fatcat_openapi_client +from fatcat_openapi_client import ApiClient, Configuration, DefaultApi -def public_api(host_uri): +def public_api(host_uri: str) -> DefaultApi: """ Note: unlike the authenticated variant, this helper might get called even if the API isn't going to be used, so it's important that it doesn't try to actually connect to the API host or something. """ - conf = fatcat_openapi_client.Configuration() + conf = Configuration() conf.host = host_uri - return fatcat_openapi_client.DefaultApi(fatcat_openapi_client.ApiClient(conf)) + return DefaultApi(ApiClient(conf)) -def authenticated_api(host_uri, token=None): +def authenticated_api(host_uri: str, token: Optional[str] = None) -> DefaultApi: """ Note: if this helper is called, it's implied that an actual API connection is needed, so it does try to connect and verify credentials. """ - conf = fatcat_openapi_client.Configuration() + conf = Configuration() conf.host = host_uri if not token: token = os.environ["FATCAT_API_AUTH_TOKEN"] @@ -33,7 +34,7 @@ def authenticated_api(host_uri, token=None): conf.api_key["Authorization"] = token conf.api_key_prefix["Authorization"] = "Bearer" - api = fatcat_openapi_client.DefaultApi(fatcat_openapi_client.ApiClient(conf)) + api = DefaultApi(ApiClient(conf)) # verify up front that auth is working api.auth_check() |