-
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
Logging rules not flagged if logger imported from another module #5694
Comments
Hi |
Will take a look. |
Looks like an oversight, we would flag |
Thanks @charliermarsh, that makes sense. |
I think I misdiagnosed this, |
…s` (#5750) ## Summary This PR adds a `logger-objects` setting that allows users to mark specific symbols a `logging.Logger` objects. Currently, if a `logger` is imported, we only flagged it as a `logging.Logger` if it comes exactly from the `logging` module or is `flask.current_app.logger`. This PR allows users to mark specific loggers, like `logging_setup.logger`, to ensure that they're covered by the `flake8-logging-format` rules and others. For example, if you have a module `logging_setup.py` with the following contents: ```python import logging logger = logging.getLogger(__name__) ``` Adding `"logging_setup.logger"` to `logger-objects` will ensure that `logging_setup.logger` is treated as a `logging.Logger` object when imported from other modules (e.g., `from logging_setup import logger`). Closes #5694.
I'm observing that logging rules aren't flagged if a logger is imported from another module.
If I set up logging here, both of these violations are flagged:
However, if I import
logger
into another module, the below identical violation is not flagged:ruff /path/to/file.py --fix
), ideally including the--isolated
flag.ruff .
pyproject.toml
)."G"
rulesetruff --version
).0.0.277
The text was updated successfully, but these errors were encountered: