import numpy as np import warnings import sys with warnings.catch_warnings(record=True) as w: sorted([1, 2], reverse=np.bool_(True)) sys.exit(len(w))