module documentation

Checker for use of Python logging.

Class LoggingChecker Checks use of the logging module.
Function is_complex_format_str Return whether the node represents a string with complex formatting specs.
Function is_method_call Determines if a BoundMethod node represents a method call.
Function register Undocumented
Function str_formatting_in_f_string Determine whether the node represents an f-string with string formatting.
Constant CHECKED_CONVENIENCE_FUNCTIONS Undocumented
Constant MOST_COMMON_FORMATTING Undocumented
Constant MSGS Undocumented
Function _count_supplied_tokens Counts the number of tokens in an args list.
def is_complex_format_str(node: nodes.NodeNG) -> bool: (source)

Return whether the node represents a string with complex formatting specs.

def is_method_call(func: bases.BoundMethod, types: tuple[str, ...] = (), methods: tuple[str, ...] = ()) -> bool: (source)

Determines if a BoundMethod node represents a method call. Args: func: The BoundMethod AST node to check. types: Optional sequence of caller type names to restrict check. methods: Optional sequence of method names to restrict check. Returns: true if the node represents a method call for the given type and method names, False otherwise.

def register(linter: PyLinter): (source)

Undocumented

def str_formatting_in_f_string(node: nodes.JoinedStr) -> bool: (source)

Determine whether the node represents an f-string with string formatting. For example: `f'Hello %s'`

CHECKED_CONVENIENCE_FUNCTIONS: set[str] = (source)

Undocumented

Value
set(['critical',
     'debug',
     'error',
     'exception',
     'fatal',
     'info',
     'warn',
...
MOST_COMMON_FORMATTING = (source)

Undocumented

Value
frozenset(['%s', '%d', '%f', '%r'])

Undocumented

Value
{'W1201': ('Use %s formatting in logging functions',
           'logging-not-lazy',
           'Used when a logging statement has a call form of "logging.<logging m
ethod>(format_string % (format_args...))". Use another type of string formatting
 instead. You can use % formatting but leave interpolation to the logging functi
on by passing the parameters as arguments. If logging-fstring-interpolation is d
isabled then you can use fstring formatting. If logging-format-interpolation is 
...
def _count_supplied_tokens(args: list[nodes.NodeNG]) -> int: (source)

Counts the number of tokens in an args list. The Python log functions allow for special keyword arguments: func, exc_info and extra. To handle these cases correctly, we only count arguments that aren't keywords. Args: args: AST nodes that are arguments for a log format string. Returns: Number of AST nodes that aren't keywords.