-
Notifications
You must be signed in to change notification settings - Fork 22
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
False positive on G003? #56
Comments
Hi @steven-murray. I tried to repro the issue here without any luck. https://github.com/globality-corp/flake8-logging-format/blob/feature/string-concat-bug/logging_format/tests/test_visitor.py#L388-L398 |
Interesting. My actual line is logger.info(f"Simulating Frequency {i+1}/{len(data_model.freqs)}") but I can't see anything much different in this than the one in the test. In case it matters, my pre-commit setup is:
|
Updated the test. Now I see some violations.
G004 seems like a legit violation. G003 would go away if not using a f-string. Isn't |
Hmmm. So I am ignoring G004 because of this issue: #32. I don't think |
I see what you are saying now. The G003 is a false positive. This plugin tries to enforce static log The readme is confusing I think because it's missing info. You need a to use a log formatter to do what it is trying to explain (magically updating message values with the extra dict key/values). Here is a formatter that does this https://github.com/globality-corp/microcosm-logging/blob/develop/microcosm_logging/formatters.py#L11 You can use this |
I think I understand the motivation for doing so, but I don't feel that it should be considered bad style to use non-static message values in logging statement, especially given that you need 3rd-party tools to enable it! So, it seems if I want some of the functionality of this plugin, but without this the G003, I should then disable both G003 and G004? |
A statement like
logger.info("This is the {i+1}th iteration")
raises G003 but this is clearly not a concatenation.The text was updated successfully, but these errors were encountered: