mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-14 01:31:32 +00:00
Allow specification of logging.Logger re-exports via logger-objects (#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 https://github.com/astral-sh/ruff/issues/5694.
This commit is contained in:
parent
727153cf45
commit
f9726af4ef
16 changed files with 197 additions and 104 deletions
|
|
@ -130,8 +130,8 @@ impl Workspace {
|
|||
external: Some(Vec::default()),
|
||||
ignore: Some(Vec::default()),
|
||||
line_length: Some(LineLength::default()),
|
||||
tab_size: Some(TabSize::default()),
|
||||
select: Some(defaults::PREFIXES.to_vec()),
|
||||
tab_size: Some(TabSize::default()),
|
||||
target_version: Some(defaults::TARGET_VERSION),
|
||||
// Ignore a bunch of options that don't make sense in a single-file editor.
|
||||
cache_dir: None,
|
||||
|
|
@ -145,8 +145,9 @@ impl Workspace {
|
|||
fixable: None,
|
||||
force_exclude: None,
|
||||
format: None,
|
||||
include: None,
|
||||
ignore_init_module_imports: None,
|
||||
include: None,
|
||||
logger_objects: None,
|
||||
namespace_packages: None,
|
||||
per_file_ignores: None,
|
||||
required_version: None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue