Skip to content

Commit fccc16d

Browse files
committed
fix: Generate a valid any() call for required parameter checks
The required parameter guard generated one any() argument per parameter, so every call raised TypeError instead of validating: any() takes a single iterable, not a variadic list of conditions. Wrap the conditions in a list and regenerate. Also fix the fallout that this masked in the rest of the suite: - Type the put and patch client helpers as returning the decoded body, matching get, post and delete, now that generated routes use them. - Set the route metadata attributes through Any, since a function does not declare them. - Allow TODO comments, which the test suite uses to track routes that cannot use the generated method yet. - Assert the GET request line and empty body in the default headers test, and drive the invalid input test through a route that still takes a JSON payload, now that /devices/get is a GET route. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFYHA1UHvARfcMBkUnWgGs
1 parent 255704d commit fccc16d

46 files changed

Lines changed: 653 additions & 506 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codegen/layouts/partials/route-method.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
def {{> method-signature}}:
33
"""{{> method-docstring}}"""
44
{{#if hasRequiredParameters}}
5-
if not any({{#each params}}{{name}} is not None{{#unless @last}}, {{/unless}}{{/each}}):
5+
if not any([{{#each params}}{{name}} is not None{{#unless @last}}, {{/unless}}{{/each}}]):
66
raise ValueError("At least one parameter is required for {{path}}")
77
{{/if}}
88
{{payloadVar}}: Dict[str, Any] = {}

pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ disable=
2020
line-too-long,
2121
too-many-lines,
2222
unnecessary-pass,
23+
fixme,
2324
redefined-outer-name,
2425
duplicate-code

seam/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ def get(self, url, **kwargs) -> Any:
9292
def post(self, url, data=None, json=None, **kwargs) -> Any:
9393
return self.request("POST", url, data=data, json=json, **kwargs)
9494

95+
def put(self, url, data=None, json=None, **kwargs) -> Any:
96+
return self.request("PUT", url, data=data, json=json, **kwargs)
97+
98+
def patch(self, url, data=None, json=None, **kwargs) -> Any:
99+
return self.request("PATCH", url, data=data, json=json, **kwargs)
100+
95101
def delete(self, url, json=None, **kwargs) -> Any:
96102
return self.request("DELETE", url, json=json, **kwargs)
97103

seam/route.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable, TypeVar
1+
from typing import Any, Callable, TypeVar, cast
22

33

44
F = TypeVar("F", bound=Callable)
@@ -8,9 +8,11 @@ def route_metadata(*, path: str, has_required_parameters: bool, has_pagination:
88
"""Attach generated route metadata to a request callable."""
99

1010
def decorate(request: F) -> F:
11-
request.__seam_path__ = path
12-
request.__seam_has_required_parameters__ = has_required_parameters
13-
request.__seam_has_pagination__ = has_pagination
11+
# Functions do not declare these attributes, so set them through Any.
12+
route = cast(Any, request)
13+
route.__seam_path__ = path
14+
route.__seam_has_required_parameters__ = has_required_parameters
15+
route.__seam_has_pagination__ = has_pagination
1416
return request
1517

1618
return decorate

seam/routes/access_codes.py

Lines changed: 75 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seam/routes/access_codes_simulate.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seam/routes/access_codes_unmanaged.py

Lines changed: 24 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)