Skip to content

Commit bb61bd8

Browse files
fix(types): resolve 2 mypy errors surfaced by the refreshed mypy
The lockfile refresh floats mypy (^1.10.1) up to 1.20.2, which is stricter and flags two pre-existing latent type issues that the older mypy missed: - auth/oauth.py:48 — is_expired() returned `exp_time and (...)`, whose value is `Any | None` (the exp claim) when falsy, not bool, violating the `-> bool` annotation. Use `exp_time is not None and (...)` so the return is a real bool and the None-exp case is explicit. - auth/retry.py:248 — the command_type setter was annotated `value: CommandType`, but the getter returns `Optional[CommandType]` and __private_init__ assigns an `Optional[CommandType]`. Widen the setter to `Optional[CommandType]` to match the getter and actual usage. Both are type-annotation-only changes; no runtime behavior change. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
1 parent 30aa6e3 commit bb61bd8

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/databricks/sql/auth/oauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def is_expired(self) -> bool:
4545
exp_time = decoded_token.get("exp")
4646
current_time = time.time()
4747
buffer_time = 30 # 30 seconds buffer
48-
return exp_time and (exp_time - buffer_time) <= current_time
48+
return exp_time is not None and (exp_time - buffer_time) <= current_time
4949
except Exception as e:
5050
logger.error("Failed to decode token: %s", e)
5151
raise e

src/databricks/sql/auth/retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def command_type(self) -> Optional[CommandType]:
245245
return self._command_type
246246

247247
@command_type.setter
248-
def command_type(self, value: CommandType) -> None:
248+
def command_type(self, value: Optional[CommandType]) -> None:
249249
self._command_type = value
250250

251251
@property

0 commit comments

Comments
 (0)