The issue
Trying to evaluate a code cell with more than one indentation results in IndentationError (although original indentation is correct). For example:

I originally thought this may be related to automatic indenting on the jupyter side, because the following works (but still adds additional indentation level):

REPR
here is an even shorter snippet - if you have access to a Windows machine and time to reproduce this (the issue is likely windows-related, see the rest of this post):
def test_fun():
a = 1
b = 2
return a, b
What I tired so far
When I previously worked with iron.nvim a similar problem would be resolved by sending --no-autoindent to ipython when starting the repl. This is unfortunatelly not possible with pyrepl, as the --no-autoindent option is not exposed via jupyter console python package.
I tried turning off autoindent by creating the following jupyter console config (in C:\Users\my_user_name\.jupyter\jupyter_console_config.py):
c = get_config()
c.InteractiveShell.autoindent = False
Now in pyrepl I see that autoindent is disabled:
from IPython import get_ipython
print(get_ipython().autoindent)
returns: False
but it didn't work
Unfortunatelly the problem with evaluating the function remains (same IndentationError). So it might be something else, possibly related to Windows (I use Windows, and run nvim on WezTerm). Do you have any ideas on what to test? I remember iron.nvim had a few windows-related issues and sends the text to the repl on windows in a slightly different way. I will like the iron.nvim issues / PRs here once I find them.
The issue
Trying to evaluate a code cell with more than one indentation results in IndentationError (although original indentation is correct). For example:

I originally thought this may be related to automatic indenting on the jupyter side, because the following works (but still adds additional indentation level):

REPR
here is an even shorter snippet - if you have access to a Windows machine and time to reproduce this (the issue is likely windows-related, see the rest of this post):
What I tired so far
When I previously worked with iron.nvim a similar problem would be resolved by sending
--no-autoindentto ipython when starting the repl. This is unfortunatelly not possible with pyrepl, as the--no-autoindentoption is not exposed via jupyter console python package.I tried turning off autoindent by creating the following jupyter console config (in
C:\Users\my_user_name\.jupyter\jupyter_console_config.py):Now in pyrepl I see that autoindent is disabled:
returns: False
but it didn't work
Unfortunatelly the problem with evaluating the function remains (same IndentationError). So it might be something else, possibly related to Windows (I use Windows, and run nvim on WezTerm). Do you have any ideas on what to test? I remember iron.nvim had a few windows-related issues and sends the text to the repl on windows in a slightly different way. I will like the iron.nvim issues / PRs here once I find them.