Skip to content

Commit 0de7c86

Browse files
cathleenyIsaac
andcommitted
fix(kernel): narrow access_token before the foreign-JWT check
mypy (check-types) rejected passing the Optional access_token to _is_foreign_jwt, because bool(access_token) does not narrow its type. Use `access_token and _is_foreign_jwt(...)` inside bool(), which narrows it. The behavior is the same; the session tests pass. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
1 parent 5082c7e commit 0de7c86

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎src/databricks/sql/session.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def _check_oauth_origin(server_hostname: str, kernel_host: str, kwargs: dict) ->
226226
access_token = kwargs.get("access_token")
227227
# A JWT from a foreign issuer is exchanged, so it is an OAuth credential even though
228228
# it arrives as access_token.
229-
foreign_jwt = bool(access_token) and _is_foreign_jwt(access_token, server_hostname)
229+
foreign_jwt = bool(access_token and _is_foreign_jwt(access_token, server_hostname))
230230
oauth = (
231231
kwargs.get("auth_type") in _OAUTH_AUTH_TYPES
232232
or kwargs.get("oauth_jwt_key_file")

0 commit comments

Comments
 (0)