Suppress spurious authlib deprecation warning in cron output

authlib 1.7 calls simplefilter("always") for AuthlibDeprecationWarning at
import time, then its own _joserfc_helpers.py imports the deprecated
authlib.jose module, emitting a warning on every run and triggering a
cron mail. Fix by importing authlib.deprecate first so our filterwarnings
"ignore" lands at position 0, ahead of authlib's "always" filter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-04-26 17:17:34 +01:00
parent 54e898bc11
commit d620ffd389

View file

@ -5,9 +5,17 @@ import asyncio
import os import os
import sys import sys
import typing import typing
import warnings
from datetime import date, datetime from datetime import date, datetime
from time import time from time import time
# authlib 1.7 registers simplefilter("always") for AuthlibDeprecationWarning at
# import time, then _joserfc_helpers.py triggers a deprecation by importing the
# old authlib.jose module. Importing authlib.deprecate first lets us insert our
# "ignore" filter at position 0 so it wins the ordering race.
import authlib.deprecate # noqa: E402 — must precede the filter below
warnings.filterwarnings("ignore", message="authlib.jose module is deprecated")
import deepdiff import deepdiff
import flask import flask
import requests import requests