Skip to content

Indentation Bug: constant dictionary #144

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions