Skip to content

Correctly raise ValueError on unknown binding in KeyBindings.remove() #2042

@buhanec

Description

@buhanec

When trying to remove from KeyBindings by Keys, an undocumented UnboundLocalError exception is raised instead of the documented ValueError.

To repro can add something like the following to test_remove_bindings:

        h3 = handlers.controla

        ...

        # Test passing unbound key sequence to the remove() function
        with pytest.raises(ValueError):
            bindings.remove(h3)
        with pytest.raises(ValueError):
            bindings.remove(Keys.ControlA)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions