jmcarp / nplusone

Auto-detecting the n+1 queries problem in Python
MIT License
1.01k stars 50 forks source link

Add warning notifier #46

Closed AlexeyBerezhnoy closed 1 year ago

AlexeyBerezhnoy commented 1 year ago

Using warnings about n+1 query is more pythonic.

warnings.warn() in library code if the issue is avoidable and the client application should be modified to eliminate the warning logging.warning() if there is nothing the client application can do about the situation, but the event should still be noted

https://docs.python.org/3/howto/logging.html#when-to-use-logging

It is also convenient to use with pytest. Because pytest creates a report on all warnings. https://docs.pytest.org/en/7.1.x/how-to/capture-warnings.html

Sorry for my english.