-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Module members with attributes named interval, rule, etc. confused for decorated functions #859
Comments
Having an interval attribute on anything callable in your module makes Sopel think it's a function it should call periodically; @interval basically just adds an interval attribute to a function. For now, you'll have to rename the attribute to something else (the actual setting in the config file can be the same, but the name of the attribute on the class has to be different). Fixing this well is a bit difficult. I don't want to just add |
Just a quick note here: this kind of issues arise in part because there is no way to tell Sopel that "this is a module", and that "this isn't a module": no meta-data, no "ModuleConfig" object, etc. nothing! As said by @embolia, as it is, it's not easy to fix, and I'm not sure it's something doable for 7.x release. |
Milestone assigned so we don't lose track of this. |
As noted in my writeup for #1931, even an innocent-looking global variable containing an innocent-looking stdlib object can trigger this. |
When I wrote this in the doc for Sopel 7:
I didn't realize that I basically got the solution for this issue. As a result, these decorators will add an attribute and set it to So yeah, it'll be done for Sopel 7.1! |
Modules with 'interval' config option don't work, they throw this error:
TypeError: 'ValidatedAttribute' object is not iterable (file "/home/julen/projects/sopel/sopel/bot.py", line 177, in register)
If i change the config option name to something else they work properle
Tryed with this to discard any other problem:
interval.py
import sopel
from sopel.config.types import ValidatedAttribute, StaticSection
class IntervalSection(StaticSection):
interval = ValidatedAttribute('interval', default='5')
def configure(config):
config.define_section('test', IntervalSection)
config.test.configure_setting(
'interval',
'interval to work'
)
def setup(bot=None):
if not bot:
return
bot.config.define_section('test', IntervalSection)
The text was updated successfully, but these errors were encountered: