Skip to content

Commit dab746f

Browse files
committed
feat: Use blueprint 0.58.1 isItemInt flag for integer list items
Number list items now map to int when the blueprint marks them with the new isItemInt flag, restoring List[int] for supported_code_lengths. All integer types now match the pre-refactor generated output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011TdqYTYvyrK8rrR7FL1Aax
1 parent 191bcb9 commit dab746f

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

codegen/lib/python-type.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
import type { Parameter, Property } from '@seamapi/blueprint'
44

5-
type ScalarFormat = Exclude<(Parameter | Property)['format'], 'list'>
5+
type ScalarFormat = Exclude<(Parameter | Property)['format'], 'list' | 'number'>
66

7-
type ListItemFormat = Extract<
8-
Parameter | Property,
9-
{ format: 'list' }
10-
>['itemFormat']
7+
type ListItem = Extract<Parameter | Property, { format: 'list' }>
118

129
export const mapParameterToPythonType = (parameter: Parameter): string => {
1310
if (parameter.format === 'list') {
14-
return `List[${mapListItemFormatToPythonType(parameter.itemFormat)}]`
11+
return `List[${mapListItemToPythonType(parameter)}]`
1512
}
1613

1714
if (parameter.format === 'number') {
@@ -23,7 +20,7 @@ export const mapParameterToPythonType = (parameter: Parameter): string => {
2320

2421
export const mapPropertyToPythonType = (property: Property): string => {
2522
if (property.format === 'list') {
26-
return `List[${mapListItemFormatToPythonType(property.itemFormat)}]`
23+
return `List[${mapListItemToPythonType(property)}]`
2724
}
2825

2926
if (property.format === 'number') {
@@ -39,25 +36,29 @@ export const mapPropertyToPythonType = (property: Property): string => {
3936
return mapScalarFormatToPythonType(property.format)
4037
}
4138

39+
const mapListItemToPythonType = (list: ListItem): string => {
40+
if (list.itemFormat === 'number') {
41+
return list.isItemInt ? 'int' : 'float'
42+
}
43+
44+
if (list.itemFormat === 'discriminated_object') {
45+
return 'Dict[str, Any]'
46+
}
47+
48+
return mapScalarFormatToPythonType(list.itemFormat)
49+
}
50+
4251
const mapScalarFormatToPythonType = (format: ScalarFormat): string => {
4352
switch (format) {
4453
case 'string':
4554
case 'datetime':
4655
case 'id':
4756
case 'enum':
4857
return 'str'
49-
// List items have no isInt flag, so numbers in lists stay floats.
50-
case 'number':
51-
return 'float'
5258
case 'boolean':
5359
return 'bool'
5460
case 'record':
5561
case 'object':
5662
return 'Dict[str, Any]'
5763
}
5864
}
59-
60-
const mapListItemFormatToPythonType = (itemFormat: ListItemFormat): string =>
61-
itemFormat === 'discriminated_object'
62-
? 'Dict[str, Any]'
63-
: mapScalarFormatToPythonType(itemFormat)

seam/routes/access_codes.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/models.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.

0 commit comments

Comments
 (0)