๐Ÿ“ฆ ftnext / happy-python-logging

๐Ÿ“„ flake8.py ยท 22 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22import ast
from collections.abc import Generator
from typing import Any

import happy_python_logging
from happy_python_logging.lint.core import ConfigureRootLoggerChecker


class HappyPythonLoggingPlugin:
    name = "flake8-happy-python-logging"
    version = happy_python_logging.__version__

    def __init__(self, tree: ast.AST) -> None:
        self._tree = tree

    def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]:
        checker = ConfigureRootLoggerChecker()
        checker.visit(self._tree)

        for lineno, col_offset, msg in checker.errors:
            yield (lineno, col_offset, msg, type(self))