wpilibsuite / sphinxext-opengraph

Sphinx extension to generate unique OpenGraph metadata
https://sphinxext-opengraph.readthedocs.io
Other
74 stars 27 forks source link

Fix DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead #99

Closed hugovk closed 1 year ago

hugovk commented 1 year ago

Fix these deprecation warnings:

tests/test_options.py::test_social_cards_svg
  /private/tmp/sphinxext-opengraph/sphinxext/opengraph/socialcards.py:103: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
    LOGGER.warn(f"[Social card] {img} cannot be an SVG image, skipping...")

tests/test_options.py::test_social_cards_svg
  /private/tmp/sphinxext-opengraph/sphinxext/opengraph/socialcards.py:108: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
    LOGGER.warn(f"[Social card]: {img} file doesn't exist, skipping...")

Also use "lazy logging":

hugovk commented 1 year ago

After this, two more:

=============================== warnings summary ===============================
tests/test_options.py::test_simple
  /opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/sphinx/util/images.py:6: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
    import imghdr

tests/test_options.py::test_no_configuration_dirhtml
  /home/runner/work/sphinxext-opengraph/sphinxext-opengraph/sphinxext/opengraph/socialcards.py:198: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
    fig = plt.figure(figsize=(ratio * multiple, multiple))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================== 35 passed, 2 warnings in 9.72s ========================

https://github.com/wpilibsuite/sphinxext-opengraph/actions/runs/4131760190/jobs/7139725073

The first is pending a fix in Sphinx: https://github.com/sphinx-doc/sphinx/issues/10440