-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Inconsistent logging detection #7502
Comments
We should be treating And we should change |
I looked into this a bit and I think it requires some minor modifications to the various rules that call |
Could it not be handled in Am I correct in thinking the issue is that |
Closed by #7521. |
## Summary Expands several rules to also check for `Expr::Name` values. As they would previously not consider: ```python from logging import error error("foo") ``` as potential violations ```python import logging logging.error("foo") ``` as potential violations leading to inconsistent behaviour. The rules impacted are: - `BLE001` - `TRY400` - `TRY401` - `PLE1205` - `PLE1206` - `LOG007` - `G001`-`G004` - `G101` - `G201` - `G202` ## Test Plan Fixtures for all impacted rules expanded. ## Issue Link Refers: #7502
## Summary `PGH002`, which checks for use of deprecated `logging.warn` calls, did not check for calls made on the attribute `warn` yet. Since #7521 we check both cases for similar rules wherever possible. To be consistent this PR expands PGH002 to do the same. ## Test Plan Expanded existing fixtures with `logger.warn()` calls ## Issue links Fixes final inconsistency mentioned in #7502
There are three ways you can call the logging module:
The logging rules are enforced inconsistently between those three call kinds:
Checking for a common logger name is generally consistent, but
PGH002
mismatches expectations here.It might also make sense to look for usages of
logging.getLogger
for a more semantic coverage, even though the vast majority of usages in the wild seem to match our pattern (see also https://grep.app/search?q=logging.getLogger&filter[lang][0]=Python, https://github.com/hummingbot/hummingbot/blob/b3ba248e7b9bab26c010fcb69a53040146084adb/hummingbot/client/config/conf_migration.py#L45, https://github.com/qutebrowser/qutebrowser/blob/4190a470c56ed90d97af89711a30c4603a347858/qutebrowser/utils/log.py#L104)The main questions i'm trying to answer are, a) should we change the scope of the existing rule (or not) and b) which of the three cases should new logging rules capture?
The text was updated successfully, but these errors were encountered: