Skip to content

Commit 264e452

Browse files
committed
Create a shadow block for None if an argument of a python function has a default value of None.
1 parent 58725a7 commit 264e452

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/blocks/utils/value.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ export function valueForFunctionArgInput(argType: string, argDefaultValue: strin
5050
break;
5151
case 'str':
5252
if (argDefaultValue === 'None') {
53-
// TODO(lizlooney): Make a block for python None
54-
// In RobotPy function hal.report(), the arg named feature has a default value of None.
55-
return null;
53+
return createNoneShadowValue()
5654
}
5755
// If argDefaultValue is surrounded by single or double quotes, it's a literal string.
5856
if (argDefaultValue.startsWith("'") && argDefaultValue.endsWith("'") ||
@@ -105,3 +103,11 @@ export function createBooleanShadowValue(boolValue: boolean): any {
105103
},
106104
}
107105
}
106+
107+
export function createNoneShadowValue(): any {
108+
return {
109+
'shadow': {
110+
'type': 'mrc_none',
111+
},
112+
}
113+
}

0 commit comments

Comments
 (0)