SQLAlchemy 2.0 emits SAWarning: Class utcnow will not make use of SQL compilation caching as it does not set the 'inherit_cache' attribute to ``True``` when using the sqlalchemy-utc package's utcnow()` SQL function expression (sqlalchemy-utc 0.14.0, its latest release, predates the SA 1.4+ caching API and doesn't set the attribute; the package is unmaintained so no upstream fix is coming).
Patch the class attribute once at your central import site, right after importing it:
from sqlalchemy_utc import utcnow
utcnow.inherit_cache = True # compilation is static; safe to cacheThis is safe because utcnow is a FunctionElement whose compiled SQL (CURRENT_TIMESTAMP AT TIME ZONE 'UTC' etc.) never varies per-instance, which is precisely what inherit_cache = True asserts. The patch both silences the SAWarning and actually enables SQL compilation caching for every statement embedding the expression — a small perf win, not just noise suppression.
Gotcha: the attribute is global to the class, but your patch module must be imported before the expression is first compiled. Put it in the module that other model files already import (e.g. your db utils), not in an optional leaf module.