Skip to content

tools, plugins: remove tools.jobs and move Job to plugins.jobs#2725

Open
Exirel wants to merge 3 commits intosopel-irc:masterfrom
Exirel:housekeeping-2476-remove-tools-jobs
Open

tools, plugins: remove tools.jobs and move Job to plugins.jobs#2725
Exirel wants to merge 3 commits intosopel-irc:masterfrom
Exirel:housekeeping-2476-remove-tools-jobs

Conversation

@Exirel
Copy link
Copy Markdown
Contributor

@Exirel Exirel commented Feb 21, 2026

Description

Fix #2476.

As per the discussion in the issue, I removed sopel.tools.job and moved the Job class to sopel.plugins.jobs. While I was there, I added a couple of tests (which required small adjustments here and there), and made sure to add versionadded or versionchanged in the docstrings.

I may want to add more tests in the future, but testing the time related multithreading thing is annoying to automate.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make lint and make test)
  • I have tested the functionality of the things this change touches

@Exirel Exirel added this to the 8.1.0 milestone Feb 21, 2026
@Exirel Exirel added Breaking Change Stuff that probably should be mentioned in a migration guide Housekeeping Code cleanup, removal of deprecated stuff, etc. Core/Plugin Handling labels Feb 21, 2026
Comment thread sopel/bot.py Dismissed
Comment thread sopel/bot.py Dismissed
Comment thread sopel/plugins/jobs.py Dismissed
Comment thread sopel/plugins/jobs.py Dismissed
Copy link
Copy Markdown
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked over perhaps 90% of this, mostly skimming over some of the trivial test changes.

Since we have the tests, most of the comments are expectedly related to docs.

Comment thread sopel/bot.py
Comment on lines -627 to -629
def unregister_jobs(self, jobs: Iterable) -> None:
for job in jobs:
self._scheduler.remove_callable_job(job)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaa, removing something with no deprecation warning in a minor version 🙀

But it's not advertised in the API docs (no docstring), so… it's probably fine? 😅

Comment thread sopel/coretasks.py
Comment on lines +181 to +187
handler = plugin.interval(wait_interval)(
plugin.label('throttle_join')(
_join_event_processing
)
)
bot.scheduler.register(job)
handler.plugin_name = 'coretasks'
bot.register_jobs([handler])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm honest, this feels a bit too "voodoo" for long-term use, even though conceptually it's just "using decorators without @ syntactic sugar". Can we make a better interface?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... on one hand, yes it's just how you can use decorators. And the other hand, the PluginJob new class is not public yet, and I'm not sure it's ready to be, even tho it's probably a very simple interface to use.

So... it's kinda hard to say what's best here.

I also want to point out that, until the PluginJob/PluginCallable rework, you had to use clean_callable to make sure it was possible to register the job: there is now one less step to do so!

Comment thread sopel/plugins/jobs.py Outdated
Comment thread sopel/plugins/jobs.py Outdated
Comment thread sopel/plugins/jobs.py Outdated
Comment thread sopel/plugins/jobs.py Outdated
Comment thread sopel/plugins/jobs.py Outdated
Comment thread sopel/plugins/jobs.py
Comment on lines +284 to +285
The ``manager`` parameter can be any kind of object; usually it's an
instance of :class:`sopel.bot.Sopel`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still true given type hints for execute() enforcing only Sopel? (Line 487)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooooh good catch. I need to see what I can do with that. Since it's now in sopel.plugins.jobs... I'd argue it should always require Sopel as the manager.

Comment thread test/plugins/test_plugins_jobs.py Outdated
Comment thread test/plugins/test_plugins_jobs.py Outdated
Co-authored-by: dgw <dgw@technobabbl.es>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking Change Stuff that probably should be mentioned in a migration guide Core/Plugin Handling Housekeeping Code cleanup, removal of deprecated stuff, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type conflict between base tools.jobs.Scheduler class and plugins.jobs.Scheduler subclass

3 participants