Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indentation Issue in ConditionalKeyBindings Example in Documentation #1938

Open
joem76 opened this issue Dec 1, 2024 · 0 comments
Open

Indentation Issue in ConditionalKeyBindings Example in Documentation #1938

joem76 opened this issue Dec 1, 2024 · 0 comments

Comments

@joem76
Copy link

joem76 commented Dec 1, 2024

Hi,

I noticed a potential indentation issue in the documentation for ConditionalKeyBindings:

The bindings = ConditionalKeyBindings(...) line appears to be indented under the is_active() function. This could confuse readers, as it implies the line is part of the function, which would result in it not being executed after the return statement.

Here’s the snippet in question (with the indentation issue):

from prompt_toolkit.key_binding import ConditionalKeyBindings

@Condition
def is_active():
    " Only activate key binding on the second half of each minute. "
    return datetime.datetime.now().second > 30

 bindings = ConditionalKeyBindings(
     key_bindings=my_bindings,
     filter=is_active)

image

This would lead to the bindings = ... line not being executed. I believe the bindings = ... line should be outside the function like this:

@Condition
def is_active():
    "Only activate key binding on the second half of each minute."
    return datetime.datetime.now().second > 30

bindings = ConditionalKeyBindings(
    key_bindings=my_bindings,
    filter=is_active
)

Could you please confirm if this is indeed an error?

Thank you for your hard work on this fantastic library! 🙏

Best,
Joe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant