chore(client): type rest of REST.post/post_best_effort + harden self._retry guard

basedpyright was still flagging on the PR view:
- path / data / json / headers untyped on post, post_best_effort,
  _request, _build_request_headers (reportMissingParameterType)
- self._retry > 0 with self._retry: Optional[int] (reportOptionalOperand)
- headers=headers passing Optional to non-Optional _request param
  (reportArgumentType)

All three classes of warning are fixed. baseline.json reduction: 20.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sriharsha Chintalapani 2026-05-16 17:31:22 -07:00
parent 61a9f376aa
commit d5551580ac
2 changed files with 16 additions and 176 deletions

View file

@ -13529,62 +13529,6 @@
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 8,
"endColumn": 14,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 8,
"endColumn": 12,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 8,
"endColumn": 12,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 8,
"endColumn": 12,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 24,
"endColumn": 28,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 27,
"endColumn": 31,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 24,
"endColumn": 28,
"lineCount": 1
}
},
{
"code": "reportOptionalCall",
"range": {
@ -13601,30 +13545,6 @@
"lineCount": 1
}
},
{
"code": "reportOptionalOperand",
"range": {
"startColumn": 39,
"endColumn": 50,
"lineCount": 1
}
},
{
"code": "reportOptionalOperand",
"range": {
"startColumn": 14,
"endColumn": 19,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 60,
"endColumn": 65,
"lineCount": 1
}
},
{
"code": "reportOptionalOperand",
"range": {
@ -13633,22 +13553,6 @@
"lineCount": 1
}
},
{
"code": "reportOperatorIssue",
"range": {
"startColumn": 49,
"endColumn": 70,
"lineCount": 1
}
},
{
"code": "reportOperatorIssue",
"range": {
"startColumn": 16,
"endColumn": 26,
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
@ -13705,54 +13609,6 @@
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 56,
"endColumn": 63,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 19,
"endColumn": 23,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 25,
"endColumn": 29,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 36,
"endColumn": 40,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 47,
"endColumn": 54,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 63,
"endColumn": 70,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
@ -13785,14 +13641,6 @@
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 67,
"endColumn": 74,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
@ -13833,14 +13681,6 @@
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 59,
"endColumn": 66,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {

View file

@ -153,13 +153,13 @@ class REST:
def _request( # noqa: C901, pylint: disable=too-many-arguments,too-many-branches
self,
method,
path,
data=None,
json=None,
base_url: URL = None,
api_version: str = None, # noqa: RUF013
headers: dict = None, # noqa: RUF013
method: str,
path: str,
data: Any = None,
json: Any = None,
base_url: Optional[URL] = None, # noqa: UP045
api_version: Optional[str] = None, # noqa: UP045
headers: Optional[dict] = None, # noqa: UP045
timeout: Optional[Union[float, tuple[float, float]]] = None, # noqa: UP007, UP045
retries: Optional[int] = None, # noqa: UP045
):
@ -230,7 +230,7 @@ class REST:
if retries is not None:
total_retries = retries if retries > 0 else 0
else:
total_retries = self._retry if self._retry > 0 else 0
total_retries = self._retry if self._retry and self._retry > 0 else 0
retry = total_retries
while retry >= 0:
try:
@ -326,10 +326,10 @@ class REST:
@calculate_execution_time(context="POST")
def post(
self,
path,
data=None,
json=None,
headers=None,
path: str,
data: Any = None,
json: Any = None,
headers: Optional[dict] = None, # noqa: UP045
timeout: Optional[Union[float, tuple[float, float]]] = None, # noqa: UP007, UP045
retries: Optional[int] = None, # noqa: UP045
):
@ -360,9 +360,9 @@ class REST:
def post_best_effort(
self,
path,
data=None,
headers=None,
path: str,
data: Any = None,
headers: Optional[dict] = None, # noqa: UP045
timeout: Optional[Union[float, tuple[float, float]]] = None, # noqa: UP007, UP045
) -> bool:
"""Quiet POST: no retries, no sleep, no logging. Returns True on 2xx."""
@ -388,7 +388,7 @@ class REST:
return False
return 200 <= resp.status_code < 300
def _build_request_headers(self, headers=None):
def _build_request_headers(self, headers: Optional[dict] = None): # noqa: UP045
"""Reader-only headers builder. Does NOT refresh auth token —
refresh stays on _request() to avoid concurrent refreshes from
post_best_effort callers sharing ClientConfig."""