Override autoscaling of contour levels in Matplotlib 3

From the API Changes for 3.0.0 docs (API Changes for 3.0.0 — Matplotlib 3.8.2 documentation):

“Selection of contour levels is now the same for contour and contourf; previously, for contour, levels outside the data range were deleted. (Exception: if no contour levels are found within the data range, the levels attribute is replaced with a list holding only the minimum of the data range.)

I have plotting code I’ve been using with Python 2.x for years and am now migrating to Python 3. I iterate over multiple comparable datasets, producing and saving equivalent plots for each. For some datasets, the data range will not include my specified contour levels. The problem is that with Matplotlib 3, contour() overrides the levels I explicitly list in this scenario, in line with the description I quote above.

Example:
Suppose data is an array with values ranging from 0-20, and I’m trying to plot a single contour level of 100.

myplot = plt.contour(x, y, data, levels=[100])
print( myplot.levels )

This code prints [0.0] to the terminal, and sure enough, the plot is a mess of unwanted contours at level 0.

Is there any mechanism to override or disable this “autoscaling” behavior? I simply want to always use the list of contour levels I provide as an argument, regardless of whether any contours will actually be plotted for a given input array.