Skip to content

Commit 9ba3373

Browse files
l0lawrenceCopilot
andcommitted
refactor(http-client-python): simplify is_typeddict_only to single models-mode check
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c8b26a94-682b-4350-a424-97093fd1c183
1 parent 24ac210 commit 9ba3373

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

  • packages/http-client-python/generator/pygen

packages/http-client-python/generator/pygen/utils.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ def is_typeddict_only(options: Any) -> bool:
3232
"""Whether generation is TypedDict-only.
3333
3434
True for TypeSpec input where no concrete models mode is selected (``models-mode: none``,
35-
normalized to a falsy value) and ``generate-typeddict`` is enabled. Swagger ``models-mode:
36-
none`` is left as a plain no-models mode because it never sets ``tsp_file``.
37-
38-
``options`` may be an :class:`OptionsDict` (where ``models-mode`` is already normalized to a
39-
falsy value) or a plain mapping (where it may still be the string ``"none"``). Both forms are
40-
treated as "no concrete models".
35+
normalized to a falsy value by :class:`OptionsDict`) and ``generate-typeddict`` is enabled.
36+
Swagger ``models-mode: none`` is left as a plain no-models mode because it never sets
37+
``tsp_file``.
4138
"""
42-
models_mode = options.get("models-mode")
43-
no_models = not models_mode or models_mode == "none"
44-
return bool(options.get("tsp_file")) and no_models and bool(options.get("generate-typeddict", True))
39+
return (
40+
bool(options.get("tsp_file"))
41+
and not options.get("models-mode")
42+
and bool(options.get("generate-typeddict", True))
43+
)
4544

4645

4746
def update_enum_value(name: str, value: Any, description: str, enum_type: dict[str, Any]) -> dict[str, Any]:

0 commit comments

Comments
 (0)