Problem
Several warnings point at a library file instead of the user's code, so the "where did this come from" line is useless:
- the Memcached
RuntimeWarnings for clear_pattern / get_all_keys point at manager.py or routes.py when they are raised through CacheManager or the monitoring routes;
- the JWT short-secret
UserWarning points at session/manager.py (SessionManager.__init__ builds the serializer).
Proposal
Check the stacklevel of every warnings.warn in the package against its real call paths. Where the depth varies, compute it (skip frames inside fastapi_cachex) instead of hard-coding it. Add tests that assert the warning's filename is the test file.
Problem
Several warnings point at a library file instead of the user's code, so the "where did this come from" line is useless:
RuntimeWarnings forclear_pattern/get_all_keyspoint atmanager.pyorroutes.pywhen they are raised throughCacheManageror the monitoring routes;UserWarningpoints atsession/manager.py(SessionManager.__init__builds the serializer).Proposal
Check the
stacklevelof everywarnings.warnin the package against its real call paths. Where the depth varies, compute it (skip frames insidefastapi_cachex) instead of hard-coding it. Add tests that assert the warning'sfilenameis the test file.