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

An idea for making willie callables syntax better. #270

Closed
1 of 3 tasks
ari-koivula opened this issue May 28, 2013 · 2 comments
Closed
1 of 3 tasks

An idea for making willie callables syntax better. #270

ari-koivula opened this issue May 28, 2013 · 2 comments
Labels
Milestone

Comments

@ari-koivula
Copy link
Contributor

Decorators could be added to willie, so that modules could use those as a standard way of declaring willie callables. They would simply add the attributes to a function, so all old modules would still work. They could later be extended to do other things, such as wrapping functions to a WillieCallable object or something.

This would also have the benefit of working nicely with IDEs, as you would get docstrings and code-completion for the decorators.

  • Make decorators for adding attributes to willie callables
    I think a new module should be made for these, meant to house things that are imported from willie modules. I would suggest "willie.module". Optionally, these could be imported to willie package for shorter syntax, but I would rather not import willie itself into a module, even if that doesn't do any harm.
import willie
# import willie.module  # I like this better.
@willie.rule(".*")
@willie.module.rule(".*")
def my_callable(bot, trigger):
  • Convert all basic modules to the new format.
    As an example for those that want to make willie modules. As I think it is preferable to adding magic attributes to function objects.
  • Add type-checking to the new decorators.
    The interface for some of these attributes is a bit complicated, so I think it would be nice to be able to run the individual module without willie and see that they are indeed in a format accepted by willie. I'm mostly talking about rule here, as it can be a regexp string or one of a few different kinds of tupples.
@elad661
Copy link
Contributor

elad661 commented May 29, 2013

Merged. Do we want the other two items blocking 4.0?

@embolalia
Copy link
Contributor

I don't think we need to worry about type/value checking, and the conversion of existing modules is covered by issue #272, so I'm closing this.

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

No branches or pull requests

3 participants