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

Fix etree deprecation warnings #93

Merged
merged 4 commits into from
Dec 22, 2021
Merged

Fix etree deprecation warnings #93

merged 4 commits into from
Dec 22, 2021

Conversation

nickmoreton
Copy link
Contributor

I have changed the import for etree to avoid the Django deprecation warnings

@zerolab
Copy link
Member

zerolab commented Dec 20, 2021

@nickmoreton thanks for this. Can you point me to the deprecation warnings?
Ideally in a changelog somewhere, but a traceback should do too

@nickmoreton
Copy link
Contributor Author

Hey @zerolab this is one of our support tickets:

/usr/local/lib/python3.8/site-packages/wagtailmarkdown/utils.py:18: DeprecationWarning: 'etree' is deprecated. Use 'xml.etree.ElementTree' instead.
from .mdx import linker, tables

Is this info enough? I can get trace tomorrow if need be.

@zerolab
Copy link
Member

zerolab commented Dec 20, 2021

That is plenty, thanks

Copy link

@tbrlpld tbrlpld left a comment

Choose a reason for hiding this comment

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

Issue: It looks like that import is only deprecated as of Markdown >= 3.2.

https://python-markdown.github.io/change_log/release-3.2/#markdownutiletree-deprecated

This project currently allows the version range Markdown>=3,<4.

We either need to add a version dependent import or limit the supported version range. I would say the former would be preferred as the impact should be smaller.

import markdown

if markdown.VERSION >= (3, 2):
    import xml.etree.ElementTree as etree
else:
    from markdown.util import etree

@zerolab
Copy link
Member

zerolab commented Dec 22, 2021

🌟@tbrlpld
This was on my list to review later today, but you beat me to it, and did a great job at it too!

@nickmoreton
Copy link
Contributor Author

@tbrlpld Thanks for the suggestion. As @zerolab says good job!

@zerolab
Copy link
Member

zerolab commented Dec 22, 2021

@nickmoreton you probably want to use __version__info (https://github.com/Python-Markdown/markdown/blob/master/markdown/__meta__.py#L29) to avoid TypeError: '>=' not supported between instances of 'str' and 'tuple'

@nickmoreton
Copy link
Contributor Author

@nickmoreton you probably want to use __version__info (https://github.com/Python-Markdown/markdown/blob/master/markdown/__meta__.py#L29) to avoid TypeError: '>=' not supported between instances of 'str' and 'tuple'

Thanks @zerolab I was busy working it out before I saw your message but used version instead. Is that OK?

@@ -14,9 +14,19 @@
Copyright 2009 - [Waylan Limberg](http://achinghead.com)
"""


import markdown
from packaging.version import Version
Copy link
Member

Choose a reason for hiding this comment

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

Wasn't sure how this would play with non-pip solutions (e.g. Conda) but it looks like Conda projects can use pip when a package is not available in the Conda repos.

From my research it seem it should all be fine. Happy to go with this.

@zerolab zerolab merged commit 343cd4f into torchbox:main Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants