Skip to content

[4.4] Add with warnings.catch_warnings() example to API docs #669

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

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1341,13 +1341,35 @@ Filter Warnings

This example shows how to suppress the :class:`neo4j.ExperimentalWarning` using the :func:`python:warnings.filterwarnings` function.

.. code-block:: python

import warnings
from neo4j import ExperimentalWarning

...

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=ExperimentalWarning)
... # the call emitting the ExperimentalWarning

...

This will only mute the :class:`neo4j.ExperimentalWarning` for everything inside
the ``with``-block. This is the preferred way to mute warnings, as warnings
triggerd by new code will still be visible.

However, should you want to mute it for the entire application, use the
following code:

.. code-block:: python

import warnings
from neo4j import ExperimentalWarning

warnings.filterwarnings("ignore", category=ExperimentalWarning)

...


********
Bookmark
Expand Down