Skip to content

Conversation

@dgw
Copy link
Member

@dgw dgw commented Dec 10, 2022

Description

Started looking at sopel.tools as a follow-up to #2379 and noticed some more cleanup that could be done. Specifically:

  • OutputRedirect class is used by nothing, appears to be a relic of the 3.x-era logging system, and should be deprecated.
  • check_pid() belongs under the cli namespace, because that's the only code that needs it. And plugins shouldn't be touching PIDs anyway.
  • stderr() also ideally should never be used by plugins. If they really really want to print directly to a terminal instead of using a logger, they have access to import sys; print('some bs', file=sys.stderr) on their own.
  • get_input() is already deprecated, but I had to replace uses of it to eliminate circular imports (because I'm perhaps foolishly keeping the moved functions available in tools until 8.1).

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 quality and make test)
  • I have tested the functionality of the things this change touches

Notes

I was going to do this stuff a bit more atomically, moving things from tools to cli in a series of several commits, but that approach ran into circular-import errors if I tried to only move one function at a time. So I'm sorry, but I couldn't find a reasonable way to break it down into smaller commits. You'll just have to review the whole thing at once. 🙏

dgw added 2 commits December 9, 2022 19:30
This looks like a remnant of Sopel's old (think 3.x days) logging setup.
We are WAY past that, and even the one plugin I thought might be abusing
it, sopel-ipython, doesn't.
A plugin isn't going to need `check_pid()`. The only usage of it at
present is within `sopel.cli`, so it definitely fits better under
`sopel.cli.utils`.

For `tools.stderr()`, ideally people are using a logger and do not print
directly to the terminal from a plugin. (And if they want to have their
plugin directly print to the terminal, removing the convenience function
from `sopel.tools` makes doing stuff The Wrong Way™ just that little bit
more annoying, which is good.)

Finally, `tools.get_input()` was already marked as deprecated but it
hadn't been replaced yet in real code with the built-in `input()`. Being
Python-3-only now, we don't have to worry about the difference between
what `input()` does in py2 and py3.

(I started out doing these in separate commits, but ran into too many
circular-import errors and eventually decided to just do ALL the things
in one go.)
@dgw dgw added Breaking Change Stuff that probably should be mentioned in a migration guide Housekeeping Code cleanup, removal of deprecated stuff, etc. labels Dec 10, 2022
@dgw dgw added this to the 8.0.0 milestone Dec 10, 2022
@dgw dgw requested a review from a team December 10, 2022 08:16
Copy link
Contributor

@SnoopJ SnoopJ left a comment

Choose a reason for hiding this comment

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

Pretty straightforward reorganization, LGTM 👍

Copy link
Contributor

@Exirel Exirel left a comment

Choose a reason for hiding this comment

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

Let's deprecate everything. 😈

@dgw dgw merged commit b2e4cde into master Dec 31, 2022
@dgw dgw deleted the more-tools-cleanup branch December 31, 2022 20:30
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 Housekeeping Code cleanup, removal of deprecated stuff, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants