-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
notifications: Switch to use make_links_absolute()
from lxml library.
#6906
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
Conversation
@HarshitOnGitHub is there any performance gain observed? Regardless, I prefer simpler codebase :> |
zerver/lib/notifications.py
Outdated
@@ -26,6 +26,7 @@ | |||
|
|||
import datetime | |||
from email.utils import formataddr | |||
import lxml.html as LH |
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 think we should just do import lxml.html
or import lxml
; no reason to use an abbreviation here.
Posted one comment, otherwise this looks good, since we have unit tests for that function so we can pretty confident there isn't something minor broken here (right?). |
Instead of using custom regexes for converting relative URLs to absolute URLs switch to using `make_links_absolute()` function from lxml library.
@timabbott Agree. Updated! Yeah we have a good test suite there so it is very unlikely that this may have broken something minor. |
Yeah we should definitely not waste time trying to see performance impact. It probably is a bit slower in a completely irrelevant way. |
Merged, thanks @HarshitOnGitHub! |
Oh, one note; do you think there's a way to handle the file uploads part with |
@timabbott I think we want abbreviation there because of this: https://stackoverflow.com/a/13093714/7516461 otherwise mypy will complain. |
I meant the second half of This works fine:
but you're right that mypy's annotations for lxml are broken; I posted on python/typeshed#525 about the issue (and added some type: ignores to our codebase). |
Instead of using custom regexes for converting relative URLs to
absolute URLs switch to using
make_links_absolute()
functionfrom lxml library.