Skip to content

Warnings point at library files instead of the caller (stacklevel) #333

Description

@allen0099

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdeveloper-experienceSurprising behaviour, missing warnings or unclear errors for library users

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions