`Signature.return_annotation` somehow turns into string when the function is ran under a marimo cell
Describe the bug
Running code snippet
from inspect import signature
def wololo(i: int, ii: int) -> tuple[str, int]:
a = i+ii
b = ii-i
c = f"{a} {b}"
return c, b
print(signature(wololo).return_annotation, type(signature(wololo).return_annotation))
on python console it prints tuple[str, int] <class 'types.GenericAlias'> according to expectation, but on a marimo cell it prints tuple[str, int] <class 'str'>, so somehow the return annotation type is a string instead of an actual type object.
Also occurs on functions with primitive return type annotations like def wololo(i: int, ii: int) -> int
Could be a inspect.signature bug too but I haven't seen any clue pointing that way yet
Environment
{
"marimo": "0.9.34",
"OS": "Linux",
"OS Version": "6.8.12-4-pve",
"Processor": "",
"Python Version": "3.11.2",
"Binaries": {
"Browser": "--",
"Node": "--"
},
"Dependencies": {
"click": "8.1.7",
"docutils": "0.21.2",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.7",
"narwhals": "1.17.0",
"packaging": "24.2",
"psutil": "6.1.0",
"pygments": "2.18.0",
"pymdown-extensions": "10.12",
"pyyaml": "6.0.2",
"ruff": "0.8.2",
"starlette": "0.41.3",
"tomlkit": "0.13.2",
"typing-extensions": "4.12.2",
"uvicorn": "0.32.1",
"websockets": "14.1"
},
"Optional Dependencies": {
"pandas": "2.2.3"
}
}
Code to reproduce
No response
It looks like a from __future__ import annotations import affects the cell runner. Is this a big issue for you, or just a curiosity?
For my own uses i can make a workaround.
Thank you for the clarification.
Closed by #3918