Skip to content

Commit

Permalink
Add with warnings.catch_warnings() example to API docs (#670)
Browse files Browse the repository at this point in the history
The new section explains how to suppress warning for only parts as opposed to
for the entire program. The former is the preferred method.
  • Loading branch information
robsdedude authored Mar 4, 2022
1 parent 3bdd5c5 commit 2af7588
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1405,13 +1405,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)
...
*********
Bookmarks
Expand Down
2 changes: 2 additions & 0 deletions docs/source/async_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Async API Documentation
This means everything documented on this page might be removed or change
its API at any time (including in patch releases).

(See :ref:`filter-warnings-ref`)

.. versionadded:: 5.0

******************
Expand Down

0 comments on commit 2af7588

Please sign in to comment.