Skip to content

Eval cog improvements #710

Merged
MarkKoz merged 24 commits into
masterfrom
eval-enhancements
Feb 28, 2020
Merged

Eval cog improvements #710
MarkKoz merged 24 commits into
masterfrom
eval-enhancements

Conversation

@Akarys42
Copy link
Copy Markdown
Contributor

@Akarys42 Akarys42 commented Dec 25, 2019

Now that snekbox support some external libraries (see python-discord/snekbox#51), I think this is a good time to work on some improvements :

It allows the cog to also work on Windows, because of Signals.SIGKILL not being defined on this platform
@Akarys42 Akarys42 added a: frontend Related to output and formatting a: tests Related to tests (e.g. unit tests) a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) p: 3 - low Low Priority t: bug Something isn't working t: feature New feature or request labels Dec 25, 2019
Akarys42 and others added 7 commits December 26, 2019 11:17
It could lead to a misleading result if it is stripped.
If the eval message is edited after less than 10 seconds, an emoji
is added to the message, and if the user adds the same, the snippet
is re-evaluated. This make easier to correct snipper mistakes.
The use of lambdas made the functions hard to test, this new format allows us to easily test those functions and document them.
…xt managers

It can be used to test aiohttp request functions, since they are async context managers
@Akarys42
Copy link
Copy Markdown
Contributor Author

Akarys42 commented Feb 9, 2020

5 tasks done out of 5, it is now ready for reviewing!

@Akarys42 Akarys42 marked this pull request as ready for review February 9, 2020 16:15
@Akarys42 Akarys42 requested a review from a team as a code owner February 9, 2020 16:15
@Akarys42 Akarys42 requested review from ikuyarihS and jerbob and removed request for a team February 9, 2020 16:15
@Akarys42 Akarys42 added p: 1 - high High Priority status: needs review and removed p: 3 - low Low Priority labels Feb 9, 2020
@ikuyarihS
Copy link
Copy Markdown
Contributor

At the moment, after calling !eval, get a result from bot, delete bot's message, change the code in the original message, click the button to re-eval will raise an error

image

Comment thread bot/cogs/snekbox.py Outdated
Comment thread bot/cogs/snekbox.py Outdated
Comment thread bot/cogs/snekbox.py Outdated
Comment thread bot/cogs/snekbox.py Outdated
Comment thread bot/cogs/snekbox.py
Comment thread bot/cogs/snekbox.py
Comment thread bot/cogs/snekbox.py Outdated
Comment thread tests/bot/cogs/test_snekbox.py Outdated
Comment thread tests/bot/cogs/test_snekbox.py Outdated
Comment thread tests/bot/cogs/test_snekbox.py Outdated
Comment thread tests/bot/cogs/test_snekbox.py Outdated
Comment thread tests/bot/cogs/test_snekbox.py Outdated
Comment thread tests/bot/cogs/test_snekbox.py Outdated
Comment thread tests/bot/cogs/test_snekbox.py Outdated
Comment thread tests/bot/cogs/test_snekbox.py Outdated
Comment thread bot/cogs/snekbox.py Outdated
Comment thread bot/cogs/snekbox.py Outdated
Akarys42 and others added 4 commits February 18, 2020 17:48
This avoid recreating partials for each re-eval
It was triggering an error if the user deleted the output before re-evaluating
Makes the code a bit clearer
Co-authored-by: Shirayuki Nekomata <lethienphuoc1991@gmail.com>
Co-Authored-By: Mark <kozlovmark@gmail.com>
Akarys42 and others added 4 commits February 18, 2020 18:25
Reads better as separate lines

Co-Authored-By: Mark <kozlovmark@gmail.com>
Reduce visual clutter

Co-Authored-By: Mark <kozlovmark@gmail.com>
Because of the stripping, it should still be considered as empty

Co-Authored-By: Mark <kozlovmark@gmail.com>
@MarkKoz MarkKoz added s: waiting for author Waiting for author to address a review or respond to a comment and removed status: needs review labels Feb 18, 2020
Copy link
Copy Markdown
Contributor

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

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

Overall I think this is quite a good pull request, mostly with clean and atomic commits and making some nice improvements. The re-eval feature, which you even wrote the issue for, is particularly well implemented.

Nice work.

Comment thread bot/cogs/snekbox.py Outdated
@Akarys42 Akarys42 requested a review from ikuyarihS February 27, 2020 09:12
Two functions were created: send_eval and continue_eval, in order to facilitate testing. The corresponding tests are also changed in this commit.
Unicode literals aren't really safe compared to code points
@Akarys42 Akarys42 requested a review from MarkKoz February 27, 2020 10:52
@Akarys42 Akarys42 removed the s: waiting for author Waiting for author to address a review or respond to a comment label Feb 27, 2020
Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

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

Thanks. The split make it look much nicer. Just several more small things.

Comment thread bot/cogs/snekbox.py Outdated
Comment thread bot/cogs/snekbox.py Outdated
Comment thread bot/cogs/snekbox.py Outdated
@Akarys42 Akarys42 requested a review from MarkKoz February 28, 2020 08:48
Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

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

This is great work. Thanks for taking the initiative to fix those bugs and, of course, add the very useful re-evaluation feature. It's a simple and intuitive design. I believe it will be much appreciate by the users (I made a change to hopefully help them know about it). 100% coverage on the test suite is impressive - I know how tedious achieving that can be, especially for larger features such as snekbox.

@MarkKoz MarkKoz dismissed ikuyarihS’s stale review February 28, 2020 17:45

Author has addressed the requested changes

@MarkKoz MarkKoz merged commit a20ab7e into master Feb 28, 2020
@MarkKoz MarkKoz deleted the eval-enhancements branch February 28, 2020 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: frontend Related to output and formatting a: tests Related to tests (e.g. unit tests) a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) p: 1 - high High Priority t: bug Something isn't working t: feature New feature or request

Projects

None yet

4 participants