-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement flake8-logging
#7248
Comments
I'm implementing |
I'm implementing |
Hm, Not to say that |
…OG009` (#7249) ## Summary Adds `LOG009` from [flake8-logging](https://github.com/adamchainz/flake8-logging). Also adds the boilerplate for a new plugin Checks for usages of undocumented `logging.WARN` constant and suggests replacement with `logging.WARNING`. ## Test Plan `cargo test` with fresh fixture ## Issue links Refers: #7248
It looks like |
|
## Summary This PR implements a new rule for `flake8-logging` plugin that checks for uses of `logging.exception()` with `exc_info` set to `False` or a falsy value. It suggests using `logging.error` in these cases instead. I am unsure about the name. Open to suggestions there, went with the most explicit name I could think of in the meantime. Refer #7248 ## Test Plan Added a new fixture cases and ran `cargo test`
Thanks! I've updated the issue description. |
Might I suggest that Currently, it is pretty confusing that To illustrate a concrete example of how this is a problem for our organization, I see here that you've marked that some of That brings me to what is an even more important point, in my opinion. Compared to I encourage you to read Adam's blog post on why he created Thanks for considering! I've had a lot of my engineers ask about switching to |
New rule |
I'm implementing LOG004 |
The recently implemented LOG015 in #14302 is in conflict with LOG002. One suggests using It also seems to be triggering when |
I can't reproduce the problem. Could you show a minimal reproducible example, please? |
The ruff docs do look surprising there - the original LOG015 docs and implementation definitely expect |
I believe the intent of LOG015 is to promote "namespaced" logging e.g. "logger.info" in favour of plain "logging.info" calls - doing so usually adds very helpful context. (Getting hold of the root logger at the start of applications to configure it should not be discouraged - but logging from it directly in "library" code.) |
Thanks. Makes sense. I created a new issue to track the resolution. |
You are right. I was confused and my comment about wrongly triggering is invalid. Thanks for the update to the doc however. |
Issue to track the implementation of
flake8-logging
rules.LOG001
use logging.getLogger() to instantiate loggersLOG002
use__name__
withgetLogger()
LOG003
extrakey '<key>'
clashes withLogRecord
attribute / Covered byG101
LOG004
avoidexception()
outside of exception handlersLOG005
useexception()
within an exception handler / Covered byTRY400
LOG006
redundantexc_info
argument forexception()
/ Covered byG202
LOG007
useerror()
instead ofexception()
withexc_info=False
LOG008
warn()
is deprecated, usewarning()
instead / Covered byG010
LOG009
WARN
is undocumented, useWARNING
insteadLOG010
exception()
does not take an exceptionLOG011
avoid pre-formatting log messages / Covered byG004
,G003
,G002
,G001
LOG012
formatting error:<n>
<style>
placeholders but<m>
argumentsLOG013
formatting error:<missing/unreferenced>
keys:<keys>
LOG014
avoidexc_info=True
outside of exception handlersLOG015
avoid logging calls on the root loggerThe text was updated successfully, but these errors were encountered: