warnings – Warn about potential code issues. — Adafruit CircuitPython 1 documentation (original) (raw)

This is a slimmed down version of the full CPython module. It defaults to the “always” action instead of “default”, which prints once per occurrence. Only “error” and “ignore” are also supported. No filtering on category is available.

This module implements a subset of the corresponding CPython module, as described below. For more information, refer to the original CPython documentation: cpython:warnings.

Available on these boards

warnings.warn(message: str, category: type = Warning) → None

Issue a warning with an optional category. Use simplefilter() to set if warnings are ignored, printed or raise an exception.

warnings.simplefilter(action: str) → None

Set the action to take on all warnings. This is a subset of the CPython behavior because it allows for per-category changes.