Created
August 22, 2022 17:10
-
-
Save jgonera/317cba59d12bc6bf287322daf36c5119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generates per-file-ignores section for the .flake8 configuration file based on | |
flake8 run output (can be either piped using STDIN or read from the file as the | |
first argument to this script). | |
Use this to disable some linting in legacy code, but keep full linting for | |
newly written code. | |
""" | |
import fileinput | |
from collections import defaultdict | |
per_file_ignores = defaultdict(set) | |
for line in fileinput.input(): | |
path, line, column, error = line.split(":", 3) | |
code, message = error.strip().split(" ", 1) | |
per_file_ignores[path].add(code) | |
for path, codes in per_file_ignores.items(): | |
print(f"{path}:{','.join(codes)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment