Skip to content

Commit 195a2f3

Browse files
author
hartsantler
committed
fixed python3 function annotations for keyword argument def f(a:int=1)
1 parent 768b8c8 commit 195a2f3

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

pythonjs/typedpython.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ def transform_source( source, strip=False ):
252252
for x in tail.split(','):
253253
y = x #x.split(')')[0]
254254
if ':' in y:
255+
kw = None
256+
if '=' in y:
257+
y, kw = y.split('=')
255258
arg, typedef = y.split(':')
256259
chan = False
257260
if len(arg.split()) == 2:
@@ -260,6 +263,8 @@ def transform_source( source, strip=False ):
260263
output.append('%s@typedef_chan(%s=%s)' %(indent, arg,typedef))
261264
else:
262265
output.append('%s@typedef(%s=%s)' %(indent, arg,typedef))
266+
if kw:
267+
arg += '=' + kw
263268
args.append(arg)
264269
else:
265270
args.append(x)
@@ -397,6 +402,8 @@ def wrapper(a:int, chan c:int):
397402
def f(a:int, b:int, c:int) ->int:
398403
return a+b+c
399404
405+
def f(a:int=100, b:int=100) ->int:
406+
return a+b
400407
401408
'''
402409

0 commit comments

Comments
 (0)