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 docutils 0.19 deprecation warnings #612

Closed
chrisjsewell opened this issue Aug 15, 2022 · 3 comments · Fixed by #842
Closed

Fix docutils 0.19 deprecation warnings #612

chrisjsewell opened this issue Aug 15, 2022 · 3 comments · Fixed by #842
Labels
help wanted Extra attention is needed testing

Comments

@chrisjsewell
Copy link
Member

Running the test suite (with tox command) now gives the following warnings:

tests/test_docutils.py: 9 warnings
tests/test_renderers/test_error_reporting.py: 18 warnings
tests/test_renderers/test_fixtures_docutils.py: 89 warnings
tests/test_renderers/test_fixtures_sphinx.py: 155 warnings
tests/test_renderers/test_include_directive.py: 8 warnings
tests/test_renderers/test_myst_config.py: 5 warnings
tests/test_renderers/test_myst_refs.py: 9 warnings
tests/test_sphinx/test_sphinx_builds.py: 57 warnings
  /Users/chrisjsewell/Documents/GitHub/myst-parser/myst_parser/mdit_to_docutils/base.py:55: DeprecationWarning: The frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
    settings = OptionParser(components=(parser_cls,)).get_default_values()

tests/test_docutils.py: 712 warnings
tests/test_renderers/test_error_reporting.py: 1224 warnings
tests/test_renderers/test_fixtures_docutils.py: 6724 warnings
tests/test_renderers/test_fixtures_sphinx.py: 10540 warnings
tests/test_renderers/test_include_directive.py: 544 warnings
tests/test_renderers/test_myst_config.py: 760 warnings
tests/test_renderers/test_myst_refs.py: 612 warnings
tests/test_sphinx/test_sphinx_builds.py: 3876 warnings
  /Users/chrisjsewell/Documents/GitHub/myst-parser/.tox/py37-sphinx5/lib/python3.7/optparse.py:1000: DeprecationWarning: The frontend.Option class will be removed in Docutils 0.21 or later.
    option = self.option_class(*args, **kwargs)

tests/test_docutils.py::test_cli_latex
  /Users/chrisjsewell/Documents/GitHub/myst-parser/myst_parser/parsers/docutils_.py:265: FutureWarning: The default for the setting "use_latex_citations" will change to "True" in Docutils 1.0.
    _run_cli("latex", "LaTeX documents", argv)

tests/test_docutils.py::test_cli_latex
  /Users/chrisjsewell/Documents/GitHub/myst-parser/myst_parser/parsers/docutils_.py:265: FutureWarning: The default for the setting "legacy_column_widths" will change to "False" in Docutils 1.0.)
    _run_cli("latex", "LaTeX documents", argv)

tests/test_docutils.py::test_help_text
  /Users/chrisjsewell/Documents/GitHub/myst-parser/tests/test_docutils.py:86: DeprecationWarning: The frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
    OptionParser(components=(Parser,)).print_help(stream)

tests/test_renderers/test_fixtures_docutils.py::test_syntax_extensions[1-dollarmath]
tests/test_renderers/test_fixtures_docutils.py::test_syntax_extensions[31-amsmath]
tests/test_renderers/test_fixtures_docutils.py::test_syntax_extensions[56-deflist]
tests/test_renderers/test_fixtures_docutils.py::test_syntax_extensions[71-fieldlist]
tests/test_renderers/test_fixtures_docutils.py::test_syntax_extensions[85-colon_fence]
tests/test_renderers/test_fixtures_docutils.py::test_syntax_extensions[97-replacements]
tests/test_renderers/test_fixtures_docutils.py::test_syntax_extensions[106-strikethrough]
tests/test_renderers/test_fixtures_docutils.py::test_syntax_extensions[122-tasklist]
  /Users/chrisjsewell/Documents/GitHub/myst-parser/tests/test_renderers/test_fixtures_docutils.py:91: DeprecationWarning: Publisher.setup_option_parser is deprecated, and will be removed in Docutils 0.21.
    option_parser = pub.setup_option_parser()

tests/test_renderers/test_fixtures_docutils.py: 8 warnings
tests/test_renderers/test_myst_config.py: 5 warnings
  /Users/chrisjsewell/Documents/GitHub/myst-parser/.tox/py37-sphinx5/lib/python3.7/site-packages/docutils/core.py:121: DeprecationWarning: The frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
    usage=usage, description=description)

tests/test_renderers/test_myst_config.py::test_cmdline[1-title-to-header]
tests/test_renderers/test_myst_config.py::test_cmdline[28-linkify]
tests/test_renderers/test_myst_config.py::test_cmdline[38-gfm-strikethrough]
tests/test_renderers/test_myst_config.py::test_cmdline[54-gfm-disallowed-html]
tests/test_renderers/test_myst_config.py::test_cmdline[81-gfm-autolink]
  /Users/chrisjsewell/Documents/GitHub/myst-parser/tests/test_renderers/test_myst_config.py:18: DeprecationWarning: Publisher.setup_option_parser is deprecated, and will be removed in Docutils 0.21.
    option_parser = pub.setup_option_parser()

Perhaps @AA-Turner could suggest any suitable fixes?

@chrisjsewell chrisjsewell added help wanted Extra attention is needed testing labels Aug 15, 2022
@chrisjsewell chrisjsewell changed the title Fox docutils 0.19 deprecation warnings Fix docutils 0.19 deprecation warnings Aug 15, 2022
@tony
Copy link

tony commented Oct 1, 2022

For downstream users:

If you run into this warning in pytest, this warning filter can hold you over:

# setup.cfg
[tool:pytest]
filterwarnings =
    ignore:The frontend.Option(Parser)? class.*:DeprecationWarning::

@AA-Turner
Copy link

AA-Turner commented Oct 3, 2022

  /Users/chrisjsewell/Documents/GitHub/myst-parser/myst_parser/mdit_to_docutils/base.py:55: DeprecationWarning: The frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
    settings = OptionParser(components=(parser_cls,)).get_default_values()

Use new API:

if docutils.__version_info__[:2] >= (0, 19):
    settings = frontend.get_default_settings(parser_cls)
else:
   settings = OptionParser(components=(parser_cls,)).get_default_values()

  /Users/chrisjsewell/Documents/GitHub/myst-parser/.tox/py37-sphinx5/lib/python3.7/optparse.py:1000: DeprecationWarning: The frontend.Option class will be removed in Docutils 0.21 or later.
    option = self.option_class(*args, **kwargs)

Global ignore (and ensure you aren't relying on any behaviour from optparse.Option).

warnings.filterwarnings('ignore', 'The frontend.Option class .*',
                        DeprecationWarning, module='docutils.frontend')

  /Users/chrisjsewell/Documents/GitHub/myst-parser/myst_parser/parsers/docutils_.py:265: FutureWarning: The default for the setting "use_latex_citations" will change to "True" in Docutils 1.0.
    _run_cli("latex", "LaTeX documents", argv)

Either switch your default, ignore the warning, or propagate to users


  /Users/chrisjsewell/Documents/GitHub/myst-parser/myst_parser/parsers/docutils_.py:265: FutureWarning: The default for the setting "legacy_column_widths" will change to "False" in Docutils 1.0.)
    _run_cli("latex", "LaTeX documents", argv)

see above


  /Users/chrisjsewell/Documents/GitHub/myst-parser/tests/test_docutils.py:86: DeprecationWarning: The frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
    OptionParser(components=(Parser,)).print_help(stream)

Local ignore

with warnings.catch_warnings():
    warnings.filterwarnings('ignore', category=DeprecationWarning)
    # DeprecationWarning: The frontend.OptionParser class will be replaced
    # by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
    OptionParser(components=(Parser,)).print_help(stream)

  /Users/chrisjsewell/Documents/GitHub/myst-parser/tests/test_renderers/test_fixtures_docutils.py:91: DeprecationWarning: Publisher.setup_option_parser is deprecated, and will be removed in Docutils 0.21.
    option_parser = pub.setup_option_parser()

Not enough context here, but don't use OptionParser objects directly--for default settings use frontend.get_default_settings(component_one, component_two, ...) or to initialise settings on a publisher use publisher.get_settings(...).


  /Users/chrisjsewell/Documents/GitHub/myst-parser/.tox/py37-sphinx5/lib/python3.7/site-packages/docutils/core.py:121: DeprecationWarning: The frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
    usage=usage, description=description)

Not enough context


  /Users/chrisjsewell/Documents/GitHub/myst-parser/tests/test_renderers/test_myst_config.py:18: DeprecationWarning: Publisher.setup_option_parser is deprecated, and will be removed in Docutils 0.21.
    option_parser = pub.setup_option_parser()

Same as above.


Hopefully helpful,
A

@chrisjsewell
Copy link
Member Author

Cheers @AA-Turner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants