You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thank you for writing calcpy, it's a great tool.
I tried to add this line to my IPython config file .config/ipython/profile_calcpy/ipython_config.py:
c.TerminalInteractiveShell.editing_mode="vi"
I then ran python3 calcpy_cli and got this error:
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3.11/pathlib.py", line 1250, in is_dir
return S_ISDIR(self.stat().st_mode)
^^^^^^^^^
AttributeError: 'str' object has no attribute 'stat'
Original exception was:
Traceback (most recent call last):
File "/home/dogeystamp/.local/bin/calcpy/calcpy_cli.py", line 109, in <module>
main()
File "/home/dogeystamp/.local/bin/calcpy/calcpy_cli.py", line 106, in main
IPython.start_ipython(ipython_args)
File "/usr/lib/python3.11/site-packages/IPython/__init__.py", line 129, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/traitlets/config/application.py", line 1043, in launch_instance
app.start()
File "/usr/lib/python3.11/site-packages/IPython/terminal/ipapp.py", line 318, in start
self.shell.mainloop()
File "/usr/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 888, in mainloop
self.interact()
File "/usr/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 873, in interact
code = self.prompt_for_code()
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 812, in prompt_for_code
text = self.pt_app.prompt(
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1035, in prompt
return self.app.run(
^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 961, in run
return loop.run_until_complete(coro)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 875, in run_async
return await _run_async(f)
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 676, in _run_async
self.reset()
File "/usr/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 432, in reset
self.vi_state.reset()
File "/usr/lib/python3.11/site-packages/prompt_toolkit/key_binding/vi_state.py", line 99, in reset
self.input_mode = InputMode.INSERT
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/IPython/terminal/shortcuts/__init__.py", line 370, in set_input_mode
sys.stdout.write(cursor)
TypeError: no_asyncio_write() missing 1 required positional argument: 'data'
It seems like the source of the error is this code from calcpy_cli.py:
# monkey patch prompt_toolkit to avoid printin from background for preview# TODO: need a better fixprompt_toolkit.patch_stdout.StdoutProxy.write= \
partial(no_asyncio_write, prompt_toolkit.patch_stdout.StdoutProxy.write)
Hi @dogeystamp 👋,
Thank you for the report and the suggested patch! ❤
Merged a fix - 42f9c16
(like you said, default value is not good enough, actually the function was completly wrong, you might have noticed that vim mode has no color even with your fix)
The code is blocking prints from the thread that is evaluating the cell while typing, so for example typing 'print(1)' won't mess up everything.
As the TODO suggests, I think I would move everything to a different process (where it can have a separate stdout) soon.
Please let me know if you have any other problems / suggestions.
Hi, thank you for writing calcpy, it's a great tool.
I tried to add this line to my IPython config file
.config/ipython/profile_calcpy/ipython_config.py
:I then ran
python3 calcpy_cli
and got this error:It seems like the source of the error is this code from calcpy_cli.py:
I patched
no_asyncio_write
like this:and it seemed to fix the crash.
Completely removing the monkey patch also fixes the crash.
I'm not quite sure what the purpose of your code is here, so I do not know if these fixes break any functionality of calcpy.
EDIT: the above
no_asyncio_write
patch is just a workaround because it fails to actually write the dataThe text was updated successfully, but these errors were encountered: