Skip to content

Commit 2fc25c2

Browse files
committed
fix: restclient _get_resource_uri typing — None-safe urljoin (CI Lint & Type Check)
The RestClientDefaults mixin extraction (commit 8db7c54) removed the only `# type: ignore[union-attr]` in restclient.py. That ignore was on `self.params.get('timeout', 60)` — but its presence happened to shape mypy's whole-file inference such that the OTHER `self.params.get('url')` call at line 139 was not flagged. With the per-line ignore gone, mypy finally sees the latent issue: - `Value of type variable "AnyStr" of "urljoin" cannot be "str | Any | None"` - `Incompatible return value type (got "str | Any | None", expected "str")` Both originate from `dict.get('url')` returning `str | None` and urljoin requiring `str`. Replace the bare get + the misplaced union-attr ignore with a None-safe pattern: base = self.params.get('url') or '' return urljoin(str(base), resource) mypy clean (155 files), flake8 clean (0), 288/288 unit pass.
1 parent 8db7c54 commit 2fc25c2

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/main/python/taf/foundation/plugins/svc/requests/restclient.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ def _set_auth(
136136
def _get_resource_uri(self, resource: str) -> str:
137137
from urllib.parse import urljoin
138138

139-
return urljoin(
140-
self.params.get('url'), # type: ignore[union-attr]
141-
resource
142-
)
139+
base = self.params.get('url') or ''
140+
return urljoin(str(base), resource)
143141

144142
# _set_default_timeout inherited from RestClientDefaults mixin.

0 commit comments

Comments
 (0)