Skip to content

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

Merged
TheTripleV merged 1 commit intosphinx-doc:mainfrom
hugovk:fix-DeprecationWarning
Feb 9, 2023
Merged

Fix DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead#99
TheTripleV merged 1 commit intosphinx-doc:mainfrom
hugovk:fix-DeprecationWarning

Conversation

@hugovk
Copy link
Copy Markdown
Contributor

@hugovk hugovk commented Feb 9, 2023

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
Copy link
Copy Markdown
Contributor Author

hugovk commented Feb 9, 2023

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: sphinx-doc/sphinx#10440

@TheTripleV TheTripleV merged commit 597ee06 into sphinx-doc:main Feb 9, 2023
@hugovk hugovk deleted the fix-DeprecationWarning branch February 9, 2023 07:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants