talonvoice / talon

Issue Tracker for the main Talon app
85 stars 0 forks source link

malformed ctx.matches hides error messages #525

Open rntz opened 2 years ago

rntz commented 2 years ago

undeclared.py

from talon import Module, Context, actions

ctx = Context()
ctx.matches = """
tag: nonexistent_tag
"""

@ctx.action_class('self')
class CtxActions:
    def undeclared_action():
        print("undeclared action go!")

This produces no errors or warnings in the log. It should produce two:

  1. tag: nonexistent_tag in ctx.matches is a reference to an undeclared tag.
  2. def undeclared_action in CtxActions is a reference to an undeclared action.

If you fix the first issue, eg. replacing tag: nonexistent_tag with os: linux, then the warning message for the second appears.

This occurred in the wild during a PR to knausj, https://github.com/knausj85/knausj_talon/pull/956.

rntz commented 2 years ago

more specific link to where it happened:

lunixbochs commented 2 years ago

I'm on the fence about how much of a Talon bug this is. For "error 1", ctx matches in general are currently allowed to match whatever text you want. I may be able to add a warning for missing tags and modes. We don't know which tags are missing at context creation time, but we can probably check it each time we evaluate which contexts are active.

As for "error 2", that's a tricky situation. We can't warn immediately upon loading a context that the action isn't defined, because there's a pretty good chance the module hasn't been loaded yet. So right now we just warn if the action is ever made active.