MCPcopy Create free account
hub / github.com/PyCQA/flake8 / __init__

Method __init__

src/flake8/processor.py:62–118  ·  view source on GitHub ↗

Initialize our file processor. :param filename: Name of the file to process

(
        self,
        filename: str,
        options: argparse.Namespace,
        lines: list[str] | None = None,
    )

Source from the content-addressed store, hash-verified

60 noqa = False
61
62 def __init__(
63 self,
64 filename: str,
65 options: argparse.Namespace,
66 lines: list[str] | None = None,
67 ) -> None:
68 """Initialize our file processor.
69
70 :param filename: Name of the file to process
71 """
72 self.options = options
73 self.filename = filename
74 self.lines = lines if lines is not None else self.read_lines()
75 self.strip_utf_bom()
76
77 # Defaults for public attributes
78 #: Number of preceding blank lines
79 self.blank_before = 0
80 #: Number of blank lines
81 self.blank_lines = 0
82 #: Checker states for each plugin?
83 self._checker_states: dict[str, dict[Any, Any]] = {}
84 #: Current checker state
85 self.checker_state: dict[Any, Any] = {}
86 #: User provided option for hang closing
87 self.hang_closing = options.hang_closing
88 #: Character used for indentation
89 self.indent_char: str | None = None
90 #: Current level of indentation
91 self.indent_level = 0
92 #: Number of spaces used for indentation
93 self.indent_size = options.indent_size
94 #: Line number in the file
95 self.line_number = 0
96 #: Current logical line
97 self.logical_line = ""
98 #: Maximum line length as configured by the user
99 self.max_line_length = options.max_line_length
100 #: Maximum docstring / comment line length as configured by the user
101 self.max_doc_length = options.max_doc_length
102 #: Whether the current physical line is multiline
103 self.multiline = False
104 #: Previous level of indentation
105 self.previous_indent_level = 0
106 #: Previous logical line
107 self.previous_logical = ""
108 #: Previous unindented (i.e. top-level) logical line
109 self.previous_unindented_logical_line = ""
110 #: Current set of tokens
111 self.tokens: list[tokenize.TokenInfo] = []
112 #: Total number of lines in the file
113 self.total_lines = len(self.lines)
114 #: Verbosity level of Flake8
115 self.verbose = options.verbose
116 #: Statistics dictionary
117 self.statistics = {"logical lines": 0}
118 self._fstring_start = self._tstring_start = -1
119

Callers

nothing calls this directly

Calls 2

read_linesMethod · 0.95
strip_utf_bomMethod · 0.95

Tested by

no test coverage detected