Skip to content

[Fix] ApiClient.send() return type should include None (#1097) - #114

Merged
rquidute merged 1 commit into
v2.16-cli-developfrom
fix/1097-api-client-send-return-type-v2.16
Sep 1, 2026
Merged

[Fix] ApiClient.send() return type should include None (#1097)#114
rquidute merged 1 commit into
v2.16-cli-developfrom
fix/1097-api-client-send-return-type-v2.16

Conversation

@rquidute

@rquidute rquidute commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

mypy th_cli/api_lib_autogen fails on freshly generated clients (via scripts/generate_client.sh):

th_cli/api_lib_autogen/api_client.py:117: error: Incompatible return value type (got "None", expected "T | str")  [return-value]

ApiClient.send() explicitly return None for 204 responses / type_=None, but is declared -> T | str, which doesn't include None.

Changes

  • scripts/datamodel_generate_client.py: fix the send() return type annotation in the generator template (T | strT | 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_compile on both files.
  • flake8 clean.
  • Verified no other code in the checked-in codebase calls ApiClient.send() directly (only through request()/request_sync(), which are already Any-typed at the implementation level).
  • Full poetry run mypy th_cli/api_lib_autogen / pytest were 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.

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
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: c1edd700-4b77-4b7a-b4ff-f48dc250e715

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rquidute
rquidute marked this pull request as ready for review September 1, 2026 12:24
@rquidute rquidute self-assigned this Sep 1, 2026
@mergify

mergify Bot commented Sep 1, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@rquidute
rquidute merged commit 0aec646 into v2.16-cli-develop Sep 1, 2026
4 checks passed
@rquidute
rquidute deleted the fix/1097-api-client-send-return-type-v2.16 branch September 1, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants