-
-
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
safety: rework #2279
safety: rework #2279
Conversation
2039502
to
e70ae7b
Compare
e70ae7b
to
076242f
Compare
fd75068
to
0544f91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking style/correctness nits.
b2fb576
to
9e51e47
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have been nudged into "actual review" territory.
c53f07f
to
57ec25c
Compare
946a422
to
feb26b3
Compare
I'm not going to dig into this much more. Just noting that I added another flake8 plugin to the todo list in #1765 after seeing the mess of imports that type-hinting this plugin added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually thought this was ready to go, but apparently not. Now that I've gone through it once more it's time to find out why GH still shows it in my "Approved 8.0.0" view, and make it not do that.
0edd88c
to
0ff6bd3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good from my perspective. Probably still wait for re-review from @Exirel to be sure everything he requested is satisfactory too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are upgrading the safety
plugin, I think we should replace all the "safety_cache"
hard-coded key into a constant, so bot.memory["satefy_cache"]
would become bot.memory[SAFETY_CACHE_KEY]
.
They are also some probable nitpick around docstrings that lack a period here and there, but I couldn't be bothered to check them all.
Should url.py import safety.SAFETY_CACHE_KEY, or just use the string? |
You can import it if you want, both option are fine by me. We can accept that URL totally depends on the safety plugin, because it kind of does. As long as safety is part of core, anyway. Which shouldn't change yet. |
I don't think URL does depend on the safety plugin - if safety is absent, url just skips those checks. Importing the constant would require a conditional to keep the dependency separate. |
It does, through the data structure that safety exposes: |
Ok, if something uses safety.py's key without following the format there will be issues, but url.py doesn't fail to perform any of its functions if safety.py is absent. I can add two more .get()s if you want, but either way I think I prefer using the string. |
If the code only even tries to read the safety info if the safety plugin is available, you minimize the chance of stepping on something else that has coopted its key name. That, to me, would be the main advantage of e.g. try:
from sopel.modules.safety import SAFETY_CACHE_KEY
except ImportError:
SAFETY_CACHE_KEY = None
# ... other code ...
# in the relevant function
if SAFETY_CACHE_KEY is not None:
# use it Is that perfect? No, because |
I'm still OK with that, as I don't think it matters too much at the moment. The Safety feature of Sopel would probably be better with a proper interface dedicated to that, instead of a Plugin. So for now, a string is fine by me. I'm just glad we could talk a bit about it, even tho it's nothing more than nitpicking at this point. |
Description
This fixes (or works towards fixing) a bunch of issues with safety.py:
.safety
doesn't say what the current state isfoo http://example.com
" fails)foo http://example.com
"Checklist
make qa
(runsmake quality
andmake test
)