my understanding is that the pyfetch from pyodide.html returns a promise, not the actual response, so you need to await the response. When you use await in a marimo cell my understanding is that marimo automatically makes that cell async.
In the example the second cell where await is used is defined as async
@app.cell
def __():
import sys
import marimo as mo
return mo, sys
@app.cell
async def __():
from pyodide.http import pyfetch
response = await pyfetch("https://raw.githubusercontent.com/caggionim/marimo_rheofit/refs/heads/main/models.py")
with open('models.py', 'wb') as file:
file.write(await response.bytes())
response = await pyfetch("https://raw.githubusercontent.com/caggionim/marimo_rheofit/refs/heads/main/rheo_widgets.py")
with open('rheo_widgets.py', 'wb') as file:
file.write(await response.bytes())