petereon / beaupy

A Python library of interactive CLI elements you have been looking for
https://petereon.github.io/beaupy/
MIT License
183 stars 13 forks source link

Bug: `raise_on_interrupt=False`doesn't work #28

Closed Cube707 closed 1 year ago

Cube707 commented 1 year ago

when runnign a example like this:

from beaupy import Config, select

Config.raise_on_interrupt = False
name = select(["A", "B"])

raise_on_interrupt = False does not work as expected. Instead using CTRL+C will still raise a interupt. This is true for readchar==3.1.0 (the currently pinnt version) and after updating to readchar==4.2.0.

The relevant reason for this is, that readchar changed it's behavior in v4 to raise interrupts by default, not passing CTRL+C to the caller. You can however disable this, if you want to handle it yourself, by changing readchar.config.INTERRUPT_KEYS (see here)

petereon commented 1 year ago

Thank you for a report, I sort of inherited the version from the package cutie without really having a look. Will fix right away

Cube707 commented 1 year ago

no hurry, I am don't need this fixed urgently.

I am the maintainer of readchar and sometimes just look around who uses it and help out with getting problems known I caused 😆

petereon commented 1 year ago

Had a quick look, did you force some update of reachar? In pyproject.toml it's capped to ^3.1.0 which would be >=3.1.0, <4.0.0

Cube707 commented 1 year ago

What do you mean by, force some update? I changed the pyproject.toml to allow for a v4 install to test if you mean that.

petereon commented 1 year ago

Yes, that is what I meant, sorry for being unclear. Anyway, thank you very much for this report! Now it should be resolved.

And big props for maintaining readchar, if you could use some help over there I'd be glad to contribute.

Cube707 commented 1 year ago

I am still wanting to implement a context-handler version of readchar, which should fix the "keypresses are dropped outside of readchar" issue and finaly enable noneblocking support.

I that peaks your interest, I will gladly accept a PR. But I will get around to it eventually myself :)

petereon commented 1 year ago

Sounds interesting, I will have a look at the codebase sometime soon.