This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add a "message" action to warnings, to trigger for every *unique* message
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: xmorel
Priority: normal Keywords:

Created on 2020-08-26 09:11 by xmorel, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg375924 - (view) Author: Xavier Morel (xmorel) * Date: 2020-08-26 09:11
Warning actions allow deduplicating warning triggers based on category ("once"), category + file ("module") and category + exact location ("default").

One thing which is missing is support for a single location generating warnings *on behalf* of other pieces of code.

`warnings.warn` provides some support via the "stacklevel" parameter, but it is difficult to compute if the warning is generated from somewhat nested generic code (or even impossible if the warning is generated from completely  generic code checking over e.g. data files or the like, or if the invoker could be invoked from multiple places with different depth difference from the code they're working for).


But in that case, the warning messages will often be unique per functional unit, so it could be a useful base for deduplication, even though the warning could dynamically be invoked multiple times (per functional unit) because e.g. code is reloaded or whatever.
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85807
2020-08-26 09:11:26xmorelcreate