mirror of https://github.com/zulip/zulip.git
ruff: Enable logging format rules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
b08c81b312
commit
5aaa36b8fc
|
@ -106,6 +106,7 @@ select = [
|
||||||
"E", # style errors
|
"E", # style errors
|
||||||
"EXE", # shebang
|
"EXE", # shebang
|
||||||
"F", # flakes
|
"F", # flakes
|
||||||
|
"G", # logging format
|
||||||
"I", # import sorting
|
"I", # import sorting
|
||||||
"ISC", # string concatenation
|
"ISC", # string concatenation
|
||||||
"N", # naming
|
"N", # naming
|
||||||
|
|
|
@ -384,12 +384,6 @@ python_rules = RuleList(
|
||||||
"pattern": "import os.path",
|
"pattern": "import os.path",
|
||||||
"description": "Use import os instead of import os.path",
|
"description": "Use import os instead of import os.path",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"pattern": r"(logging|logger)\.warn\W",
|
|
||||||
"description": "Logger.warn is a deprecated alias for Logger.warning; Use 'warning' instead of 'warn'.",
|
|
||||||
"good_lines": ["logging.warning('I am a warning.')", "logger.warning('warning')"],
|
|
||||||
"bad_lines": ["logging.warn('I am a warning.')", "logger.warn('warning')"],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"pattern": r"\.pk",
|
"pattern": r"\.pk",
|
||||||
"exclude_pattern": "[.]_meta[.]pk",
|
"exclude_pattern": "[.]_meta[.]pk",
|
||||||
|
|
|
@ -42,32 +42,6 @@ rules:
|
||||||
- zerver/migrations/0387_reupload_realmemoji_again.py
|
- zerver/migrations/0387_reupload_realmemoji_again.py
|
||||||
- pgroonga/migrations/0002_html_escape_subject.py
|
- pgroonga/migrations/0002_html_escape_subject.py
|
||||||
|
|
||||||
- id: logging-format
|
|
||||||
languages: [python]
|
|
||||||
patterns:
|
|
||||||
- pattern-either:
|
|
||||||
- pattern: $LOGGER.debug($FORMATTED, ...)
|
|
||||||
- pattern: $LOGGER.info($FORMATTED, ...)
|
|
||||||
- pattern: $LOGGER.warning($FORMATTED, ...)
|
|
||||||
- pattern: $LOGGER.error($FORMATTED, ...)
|
|
||||||
- pattern: $LOGGER.critical($FORMATTED, ...)
|
|
||||||
- pattern: $LOGGER.exception($FORMATTED, ...)
|
|
||||||
- pattern: $LOGGER.log($LEVEL, $FORMATTED, ...)
|
|
||||||
- metavariable-pattern:
|
|
||||||
metavariable: $LOGGER
|
|
||||||
patterns:
|
|
||||||
- pattern-either:
|
|
||||||
- pattern: logging
|
|
||||||
- pattern: logger
|
|
||||||
- metavariable-pattern:
|
|
||||||
metavariable: $FORMATTED
|
|
||||||
patterns:
|
|
||||||
- pattern-either:
|
|
||||||
- pattern: ... .format(...)
|
|
||||||
- pattern: f"..."
|
|
||||||
severity: ERROR
|
|
||||||
message: "Pass format arguments to logging (https://docs.python.org/3/howto/logging.html#optimization)"
|
|
||||||
|
|
||||||
- id: sql-format
|
- id: sql-format
|
||||||
languages: [python]
|
languages: [python]
|
||||||
pattern-either:
|
pattern-either:
|
||||||
|
|
Loading…
Reference in New Issue