Skip to content

Commit 16d1f38

Browse files
authored
Add circleci to run flake8 (#28)
* Add files required for circleci * Add circleCI badge * Show the error while also storing it * Fix up linting issues Add a default config Fix outputting results from flake8 * Actually update flake8 command * Fix E722 do not use bare except
1 parent 074d66e commit 16d1f38

File tree

6 files changed

+62
-10
lines changed

6 files changed

+62
-10
lines changed

.circleci/config.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Python CircleCI 2.0 configuration file
2+
version: 2
3+
jobs:
4+
build:
5+
docker:
6+
- image: circleci/python:3.6.4
7+
8+
steps:
9+
- checkout
10+
11+
- restore_cache:
12+
keys:
13+
- v1-dependencies-{{ checksum "requirements.txt" }}
14+
- v1-dependencies-
15+
16+
- run:
17+
name: install dependencies
18+
command: |
19+
python3 -m venv venv
20+
. venv/bin/activate
21+
pip install -r requirements.txt
22+
23+
- save_cache:
24+
paths:
25+
- ./venv
26+
key: v1-dependencies-{{ checksum "requirements.txt" }}
27+
28+
- run:
29+
name: run linting and metrics
30+
command: |
31+
python3 -m venv venv
32+
. venv/bin/activate
33+
flake8 . --output-file test-reports --tee --statistics
34+
35+
- store_artifacts:
36+
path: test-reports
37+
destination: test-reports

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,6 @@ ENV/
8787

8888
# Rope project settings
8989
.ropeproject
90+
91+
# Additions
92+
test-reports

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![GitHub contributors](https://img.shields.io/github/contributors/psykzz/st3-gitblame.svg)](https://github.com/psykzz/st3-gitblame/graphs/contributors)
22
[![GitHub issues](https://img.shields.io/github/issues/psykzz/st3-gitblame.svg)](https://github.com/psykzz/st3-gitblame/issues)
3+
[![CircleCI](https://circleci.com/gh/psykzz/st3-gitblame.svg?style=svg)](https://circleci.com/gh/psykzz/st3-gitblame)
34

45

56
# Git blame - Sublime text 3 plugin

git-blame.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
try:
104104
si = subprocess.STARTUPINFO()
105105
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
106-
except:
106+
except Exception:
107107
si = None
108108

109109

@@ -116,11 +116,12 @@ def __init__(self, view):
116116
@functools.lru_cache(128, False)
117117
def get_blame(self, line, path):
118118
try:
119-
return shell(["git", "blame", "--minimal", "-w",
120-
"-L {0},{0}".format(line), path],
119+
return shell(
120+
["git", "blame", "--minimal", "-w", "-L {0},{0}".format(line), path],
121121
cwd=os.path.dirname(os.path.realpath(path)),
122122
startupinfo=si,
123-
stderr=subprocess.STDOUT)
123+
stderr=subprocess.STDOUT
124+
)
124125
except subprocess.CalledProcessError as e:
125126
print("Git blame: git error {}:\n{}".format(e.returncode, e.output.decode("UTF-8")))
126127
except Exception as e:
@@ -145,9 +146,11 @@ def parse_blame(self, blame):
145146

146147
def get_commit(self, sha, path):
147148
try:
148-
return shell(["git", "show", sha],
149+
return shell(
150+
["git", "show", sha],
149151
cwd=os.path.dirname(os.path.realpath(path)),
150-
startupinfo=si)
152+
startupinfo=si
153+
)
151154
except Exception as e:
152155
return
153156

@@ -182,8 +185,9 @@ def run(self, edit):
182185

183186
phantoms = []
184187
self.view.erase_phantoms('git-blame')
185-
#Before adding the phantom, see if the current phantom that is displayed is at the same spot at the selection
186-
if self.phantom_set.phantoms and self.view.line(self.view.sel()[0]) == self.view.line(self.phantom_set.phantoms[0].region):
188+
# Before adding the phantom, see if the current phantom that is displayed is at the same spot at the selection
189+
phantom_exists = self.view.line(self.view.sel()[0]) == self.view.line(self.phantom_set.phantoms[0].region)
190+
if self.phantom_set.phantoms and phantom_exists:
187191
self.phantom_set.update(phantoms)
188192
return
189193

@@ -265,10 +269,12 @@ def get_blame_lines(self, path):
265269
try:
266270
# The option --show-name is necessary to force file name display.
267271
command = ["git", "blame", "--show-name", "--minimal", "-w", path]
268-
output = shell(command,
272+
output = shell(
273+
command,
269274
cwd=os.path.dirname(os.path.realpath(path)),
270275
startupinfo=si,
271-
stderr=subprocess.STDOUT)
276+
stderr=subprocess.STDOUT
277+
)
272278
return output.decode("UTF-8").splitlines()
273279
except subprocess.CalledProcessError as e:
274280
print("Git blame: git error {}:\n{}".format(e.returncode, e.output.decode("UTF-8")))

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flake8

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
exclude = .git,__pycache__,venv
3+
max-complexity = 10
4+
max-line-length = 120

0 commit comments

Comments
 (0)