Fix Python deprecation warnings (LOGGER.warn, datetime.utcnow, docutils 2.0)#3894
Fix Python deprecation warnings (LOGGER.warn, datetime.utcnow, docutils 2.0)#3894arunpersaud wants to merge 5 commits into
Conversation
felixfontein
left a comment
There was a problem hiding this comment.
While most changes look good, I'm not sure requiring docutils >= 0.22 is a good idea. 0.22 got released less than a year ago, and is likely not available on some of the platforms Nikola should work on. Ubuntu 24.04 for example only 0.20.1, and even Ubuntu 25.10 only has 0.21.2. (Ubuntu 26.04 has 0.22.4.)
| from docutils import nodes | ||
| from docutils.parsers.rst import Directive, directives | ||
| from docutils.parsers.rst.roles import set_classes | ||
| from docutils.parsers.rst.roles import normalize_options |
There was a problem hiding this comment.
Here I would use a conditional import:
| from docutils.parsers.rst.roles import normalize_options | |
| try: | |
| from docutils.parsers.rst.roles import normalize_options | |
| except ImportError: | |
| from docutils.parsers.rst.roles import set_classes as normalize_options |
This way it also works with docutils < 0.22.
There was a problem hiding this comment.
good point, reverted this partially and added the above
| settings=settings, | ||
| source_class=source_class, | ||
| destination_class=docutils.io.StringOutput) | ||
| pub.set_components(None, parser_name, writer_name) |
There was a problem hiding this comment.
This one is harder. Maybe conditional code based on the docutils version will work here?
There was a problem hiding this comment.
I just reverted this for now
…the deprecated warning using normalize_options when available
|
@felixfontein thanks for looking at this. Let me know if this looks better |
Pull Request Checklist
Description
Updates deprecated APIs to their modern equivalents for better Python 3.13+ compatibility. These showed up in 'ty' and pytest.