[Fix] ApiClient.send() return type should include None (#1097) - #114
Conversation
send() explicitly returns None for 204 responses / type_=None, but was declared -> T | str, which doesn't include None. Running mypy on a freshly generated client (scripts/generate_client.sh) fails with: api_client.py:117: error: Incompatible return value type (got "None", expected "T | str") [return-value] Fix the annotation in both the checked-in generated file and the generator template it comes from (scripts/datamodel_generate_client.py), so future regenerations don't reintroduce the error. Fixes #1097
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Tick the box to add this pull request to the merge queue (same as
|
Description
mypy th_cli/api_lib_autogenfails on freshly generated clients (viascripts/generate_client.sh):ApiClient.send()explicitlyreturn Nonefor 204 responses /type_=None, but is declared-> T | str, which doesn't includeNone.Changes
scripts/datamodel_generate_client.py: fix thesend()return type annotation in the generator template (T | str→T | str | None).th_cli/api_lib_autogen/api_client.py: apply the same fix to the currently checked-in generated file, so it matches what regenerating against a live backend now produces.Related
Fixes #1097 (project-chip/certification-tool), filed while validating #113 — confirmed pre-existing/identical on
v2.16-cli-develop, unrelated to that PR's changes.Testing
python3 -m py_compileon both files.flake8clean.ApiClient.send()directly (only throughrequest()/request_sync(), which are alreadyAny-typed at the implementation level).poetry run mypy th_cli/api_lib_autogen/pytestwere not run in the environment this was authored in (no network access to install the CLI's pydantic v2 dependencies) — please confirm on your machine before merging. This should resolve the exact error reported from a live-backend codegen run.