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

plugins: check consistency of plugin code and their output formatting #1937

Merged
merged 41 commits into from
Sep 16, 2020

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented Sep 12, 2020

Description

I'm trying to fix, at least partially, issue #709 which turned out differently than what I expected.

So in the end, I also checked the code's consistency, and decided to:

  • use bot.reply in case of error
  • remove if main block (they are pointless)
  • replace sopel.module by sopel.plugin; we know it works, it's fine, let's move on with our life
  • replace return bot.reply statement because a one-liner that makes no sense is harmful to beginner who might not understand what we are trying to achieve with it; also the code should express the intent, it is not a showcase of how smart you are at reducing the file length (mood: 😠)
  • curse in French (a lot)
  • normalize import as much as possible (using from sopel import plugin instead of anything else)
  • a lot of cursing in French actually (:fr: :cursing_face:)
  • completely ignore eventually did the meetbot plugin, and that one can go 🇫🇷 🤬 itself
  • not fix the tld plugin, it looks complicated and I hate it—go read on Wikipedia you lazy nerd!
  • listening to darksynth/EDM music, that has nothing to do with Sopel but it was necessary while doing that

If anyone complain or have comments or suggestion: this PR is here to fix #709 so you too can help, so please do!

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

@Exirel Exirel added the Tweak label Sep 12, 2020
@Exirel Exirel added this to the 7.1.0 milestone Sep 12, 2020
@lgtm-com
Copy link

lgtm-com bot commented Sep 12, 2020

This pull request introduces 1 alert when merging b4961a8 into 528e1b8 - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

@dgw dgw self-requested a review September 13, 2020 11:02
Copy link
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 a vested interest in getting this done and merged soon, since I built another PR on top of it to save on rebasing work later. So I hope you'll not be too annoyed by my suggestions here, and we can get this whipped into shape faster than that interminable plugin-chapter doc PR we just finished. 😹

sopel/modules/adminchannel.py Show resolved Hide resolved
sopel/modules/announce.py Outdated Show resolved Hide resolved
sopel/modules/calc.py Show resolved Hide resolved
sopel/modules/calc.py Show resolved Hide resolved
sopel/modules/clock.py Show resolved Hide resolved
sopel/modules/uptime.py Show resolved Hide resolved
sopel/modules/url.py Show resolved Hide resolved
sopel/modules/version.py Outdated Show resolved Hide resolved
sopel/modules/wikipedia.py Show resolved Hide resolved
sopel/modules/xkcd.py Show resolved Hide resolved
@dgw
Copy link
Member

dgw commented Sep 14, 2020

Whoops, forgot to check LGTM's comment before submitting that review. It has a point. find_updates.py is kind of awkward now with the overlapping imports.

@lgtm-com
Copy link

lgtm-com bot commented Sep 14, 2020

This pull request introduces 1 alert when merging 0b471de into 58bd737 - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

@Exirel
Copy link
Contributor Author

Exirel commented Sep 14, 2020

I'll hate the squash & rebase that will come. And all the potential merge conflict to come.

Oh well, it has to be done.

@dgw waiting on your approval.

Copy link
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.

Once I managed to coax a "changes since last review" view out of GitHub (only accessible from the Conversation tab, for some reason; the Files tab dropdown had that option greyed out), this was a pretty easy re-review. Just a couple little things, and one additional can of worms opened accidentally by the added tweaks to those few command docstrings that started with """.… 😅

sopel/modules/xkcd.py Outdated Show resolved Hide resolved
sopel/modules/ip.py Show resolved Hide resolved
sopel/modules/uptime.py Show resolved Hide resolved
Copy link
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.

Between the last little tweaks and the follow-up items added to my to-do list, this should be good to go. Squash when ready!

Copy link
Contributor

@Duckle29 Duckle29 left a comment

Choose a reason for hiding this comment

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

Only looked at currency, but LGTM 👍

@dgw
Copy link
Member

dgw commented Sep 14, 2020

@Duckle29 thanks for the extra eyes! 🙌

* replaced `sopel.module` by `sopel.plugin`
* replaced `reply` by `say` in private message only commands
* replaced `sopel.module` by `sopel.plugin`
* replaced duplicated text by a constant
* replaced `return bot.reply` by 2 lines

Note: `bot.reply`'s return has no meaning. Using it in a return
statement creates confusion as to why it is used in such a way.
Therefore, it should **not** be used that way.
* replaced `sopel.module` by `sopel.plugin`
* added output prefix
* replaced `sopel.module` by `sopel.plugin`
* used output prefix with `bot.say`
* removed obsolete "if main" block
* replaced `sopel.module` by `sopel.plugin`
* removed obsolete "if main" block
* replaced `sopel.module` by `sopel.plugin`
* used output prefix with `bot.say`
* replaced common error messages by constants
* replaced `sopel.module` by `sopel.plugin`
* used output prefix with `bot.say`
* replaced `sopel.module` by `sopel.plugin`
* used output prefix with `bot.say`
* removed `return plugin.NOLIMIT` from `exchange` function as this
  return value is not used by its callers
* replaced `sopel.module` by `sopel.plugin`
* used output prefix with `bot.say`
* removed obsolete "if main" block
* replaced `sopel.module` by `sopel.plugin`
* no output prefix for emotes, they are too pure!
* replaced `sopel.module` by `sopel.plugin`
* replaced `sopel.module` by `sopel.plugin`
* add manual output prefix in job
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* replaced `Likes: N` by `N ♥`` with proper singular/plural
* replaced `Comments: N` by `N comment` with proper singular/plural
* replaced `sopel.module` by `sopel.plugin`
* replaced `return bot.reply` by 2 lines
* replaced `sopel.module` by `sopel.plugin`
* replaced `bot.say` by `bot.reply` for error cases
* replaced `return bot.reply` by 2 lines
* removed obsolete `if main` block
* replaced `sopel.module` by `sopel.plugin`
* removed obsolete `if main` block
* replaced `sopel.module` by `sopel.plugin`
* removed obsolete `if main` block
* replaced `sopel.module` by `sopel.plugin`
* replaced `bot.say` by `bot.reply` for error cases
* replaced `return bot.reply` by 2 lines
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* replaced `bot.say` by `bot.reply` for error cases
* replaced `return bot.reply` by 2 lines
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`

Note: I didn't use bot.say as .in and .at inform the user that their
action succeeded *for them*. It's a very specific case and I didn't
feel like using `bot.say` here.
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* replaced `return bot.reply` by 2 lines
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* replaced `return bot.reply` by 2 lines
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method

Note: apparently TLD parsing is broken. This won't fix it.
* replaced `sopel.module` by `sopel.plugin`
* replaced `return bot.reply` by 2 lines
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* removed obsolete `if main` block
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* removed obsolete `if main` block
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* removed obsolete `if main` block
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method
* replaced `sopel.module` by `sopel.plugin`
* used `plugin.output_prefix` with `bot.say` method

And in theory, I'm done!
@Exirel
Copy link
Contributor Author

Exirel commented Sep 15, 2020

Squashed, rebased: 🚢

@dgw dgw merged commit 19522fc into sopel-irc:master Sep 16, 2020
@dgw
Copy link
Member

dgw commented Sep 16, 2020

  • completely ignore the meetbot plugin, this one can go 🇫🇷 🤬 itself

In the end, this was a lie, since you did touch it after all. 😹

  • not fix the tld plugin, it looks complicated and I hate it—go read on Wikipedia you lazy nerd!

But saying this motivated someone else (me) to work on it, with a PR coming Soon™ to a repo near you! (Pro tip: It was a lot less complicated to just rewrite the whole thing with a different strategy than to fix the regex. 😁)

dgw added a commit that referenced this pull request Nov 22, 2020
reddit: remove stray hard-coded message prefix missed in #1937
@Exirel Exirel deleted the consistency-plugins-output branch May 1, 2021 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify consistency of plugin output formatting
3 participants