浏览代码

Fix flake8 warnings and check it

Vadim Markovtsev 6 年之前
父节点
当前提交
f0db0b3136
共有 4 个文件被更改,包括 12 次插入7 次删除
  1. 3 0
      .flake8
  2. 2 1
      .travis.yml
  3. 2 1
      contrib/_plugin_example/plot_churn.py
  4. 5 5
      labours.py

+ 3 - 0
.flake8

@@ -0,0 +1,3 @@
+[flake8]
+max-line-length=99
+exclude=.git,internal/pb/pb_pb2.py

+ 2 - 1
.travis.yml

@@ -54,7 +54,7 @@ before_install:
   - export PATH=~/usr/bin:$PATH
   - make --version
   - pip3 --version
-  - pip3 install --user --no-build-isolation -r requirements.txt tensorflow
+  - pip3 install --user --no-build-isolation -r requirements.txt tensorflow flake8
   - docker run -d --privileged -p 9432:9432 --name bblfshd bblfsh/bblfshd
   - docker exec -it bblfshd bblfshctl driver install python bblfsh/python-driver:latest
   - docker exec -it bblfshd bblfshctl driver install go bblfsh/go-driver:latest
@@ -68,6 +68,7 @@ script:
   - set -e
   - go vet -tags tensorflow ./...
   - golint -set_exit_status ./...
+  - flake8
   - if [[ $TRAVIS_GO_VERSION != 1.9.* ]]; then go test -coverpkg=all -v -cpu=1,2 -coverprofile=coverage.txt -covermode=count gopkg.in/src-d/hercules.v4/... && sed -i '/cmd\/hercules\|core.go/d' coverage.txt; fi
   - if [[ $TRAVIS_GO_VERSION = 1.9.* ]]; then go test -v -cpu=1,2 gopkg.in/src-d/hercules.v4/...; fi
   - $GOPATH/bin/hercules version

+ 2 - 1
contrib/_plugin_example/plot_churn.py

@@ -59,7 +59,8 @@ def plot_churn(name, data, url, beginTime, endTime, output, fmt, tick_interval):
         spine.set_visible(False)
     pyplot.gca().xaxis.set_major_locator(mdates.DayLocator(interval=tick_interval))
     pyplot.gca().xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d"))
-    pyplot.tick_params(top="off", bottom="off", left="off", right="off", labelleft="off", labelbottom="on")
+    pyplot.tick_params(top="off", bottom="off", left="off", right="off",
+                       labelleft="off", labelbottom="on")
     pyplot.bar(df.index, df["additions"], label="additions")
     pyplot.bar(df.index, df["removals"], label="removals")
     pyplot.plot(df.index, effective, "black", label="effective")

+ 5 - 5
labours.py

@@ -24,7 +24,7 @@ import yaml
 
 if sys.version_info[0] < 3:
     # OK, ancients, I will support Python 2, but you owe me a beer
-    input = raw_input
+    input = raw_input  # noqa: F821
 
 
 PB_MESSAGES = {
@@ -648,7 +648,7 @@ def deploy_plot(title, output, style):
             pyplot.title(title, color=style)
         try:
             pyplot.tight_layout()
-        except:
+        except:  # noqa: E722
             print("Warning: failed to set the tight layout")
         pyplot.savefig(output, transparent=True)
     pyplot.clf()
@@ -838,6 +838,7 @@ def plot_ownership(args, repo, names, people, date_range, last):
         output = args.output
     deploy_plot("%s code ownership through time" % repo, output, args.style)
 
+
 IDEAL_SHARD_SIZE = 4096
 
 
@@ -972,7 +973,7 @@ class CORSWebServer(object):
 
         try:
             from http.server import HTTPServer, SimpleHTTPRequestHandler, test
-        except ImportError: # Python 2
+        except ImportError:  # Python 2
             from BaseHTTPServer import HTTPServer, test
             from SimpleHTTPServer import SimpleHTTPRequestHandler
 
@@ -981,9 +982,8 @@ class CORSWebServer(object):
                 HTTPServer.__init__(self, *args, **kwargs)
                 outer.server = self
 
-
         class CORSRequestHandler(SimpleHTTPRequestHandler):
-            def end_headers (self):
+            def end_headers(self):
                 self.send_header("Access-Control-Allow-Origin", "*")
                 SimpleHTTPRequestHandler.end_headers(self)