Skip to content

Indentation Bug: constant dictionary #144

@Wsine

Description

@Wsine

A minimal example is as below. every step I only type o to trigger to indentation.

Animation

import logging

# from: https://stackoverflow.com/a/56944256
class CustomFormatter(logging.Formatter):
    GREY = "\x1b[38;20m"
    YELLOW = "\x1b[33;20m"
    BLUE = "\x1b[34;20m"
    RED = "\x1b[31;20m"
    BOLD_RED = "\x1b[31;1m"
    RESET = "\x1b[0m"
    CONTENT = "%(levelname)s - %(message)s (%(filename)s:%(lineno)d)"

    FORMATS = {
        logging.DEBUG: BLUE + CONTENT + RESET,
        logging.INFO: GREY + CONTENT + RESET,
        logging.WARNING: YELLOW + CONTENT + RESET,
        logging.ERROR: RED + CONTENT + RESET,
        logging.CRITICAL: BOLD_RED + CONTENT + RESET
    }

    def format(self, record):
        log_fmt = self.FORMATS.get(record.levelno)
        formatter = logging.Formatter(log_fmt)
        return formatter.format(record)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions