-
Notifications
You must be signed in to change notification settings - Fork 158
Description
Description
I was digging through the generated SDK code and found something that looks... off.
The weird type comparison
Every API method has this pattern:
if error:
if List[User] is Success:
return (None, error)
else:
return (None, None, error)Unless I'm missing something, List[User] is Success is comparing two completely unrelated types via identity - this will always be False. The if branch is dead code.
Looking at openapi/templates/api.mustache, I think I see what happened:
{{#returnType}}
if {{returnType}} is Success:
return (None, error)
else:
return (None, None, error)
{{/returnType}}It looks like this was meant to be a generation-time decision (emit different code depending on whether the return type is Success), but instead {{returnType}} gets string-substituted into a runtime check. So when returnType = "List[User]", you get the nonsense comparison.
Return type annotations don't match actual returns
The functions are annotated like:
async def list_users(...) -> List[User]:But they actually return tuples like (data, response, error) or (None, None, error). Running mypy/pyright on code that uses this SDK would be a mess.
Am I reading this wrong?
Maybe there's some magic happening that I'm not seeing, but from what I can tell:
- The
is Successcheck is always false for non-Success return types - The return annotations claim to return the data type directly, but functions return tuples
Is this intentional?
Would you like to implement a relevant change?
No