Created
April 11, 2019 21:31
-
-
Save AlexArcPy/4d15c61d6b7fe8e1ae7af83ad5a30d0c to your computer and use it in GitHub Desktop.
Flake8 snippets
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
# flake8 > C:/Temp/StyleGuide.csv | |
import os | |
os.chdir('C:/Temp') | |
import pandas as pd | |
for errors_file in ['StyleGuide1.csv', 'StyleGuide2.csv']: | |
df = pd.read_csv(errors_file, sep=':') | |
df.columns = ['FilePath', 'LineNo', 'ColumnNo', 'ErrorMessage'] | |
df = df[['FilePath', 'LineNo', 'ColumnNo', 'ErrorMessage']] | |
df['ErrorCode'] = df['ErrorMessage'].str[:5] | |
df['ErrorMessage'] = df['ErrorMessage'].str[6:] | |
agg = df.groupby(['ErrorCode', 'ErrorMessage']).size().reset_index(name='Count') | |
agg.sort_values(['Count', 'ErrorCode'], inplace=True) | |
agg.to_csv("_agg" + errors_file, index=False) |
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
# get files that have been changed in the 5 last commits | |
$ git diff HEAD HEAD~5 --name-only > C:/Temp/diff_files.txt | |
# feed each file to flake8 | |
$ cat C:/Temp/diff_files.txt | grep .py | xargs flake8 --filename | |
# single-line command | |
git diff HEAD HEAD~5 --name-only | grep .py | xargs flake8 --filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment