From c4c07bd84da58bbb07d2ce4f53bedb5d5ef217a1 Mon Sep 17 00:00:00 2001 From: Darafei Praliaskouski Date: Sat, 22 Jun 2019 20:05:00 +0000 Subject: [PATCH] [travis] Lint Python code for syntax errors Patch by Christian Clauss Closes #411 git-svn-id: http://svn.osgeo.org/postgis/trunk@17556 b70326c6-7e19-0410-871a-916f4a2858ee --- .travis.yml | 7 ++++++- raster/scripts/python/raster2pgsql.py | 2 +- raster/scripts/python/rtreader.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e919a4df1..d527f6754 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ services: - docker -sudo: true language: c env: @@ -20,6 +19,12 @@ env: matrix: allow_failures: - env: tag=latest mode=tests + include: + - name: "Lint: python3 -m flake8 . --select=E9,F63,F72,F82" + language: python + script: + - pip install flake8 # lint Python code for syntax errors + - flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics script: - echo "/tmp/logbt-coredumps/core.%p.%E" | sudo tee /proc/sys/kernel/core_pattern diff --git a/raster/scripts/python/raster2pgsql.py b/raster/scripts/python/raster2pgsql.py index fb4dd1e62..b4ceee7a7 100755 --- a/raster/scripts/python/raster2pgsql.py +++ b/raster/scripts/python/raster2pgsql.py @@ -670,7 +670,7 @@ def wkblify_raster_header(options, ds, level, ulp, xsize = None, ysize = None): """Writes WKT Raster header based on given GDAL into HEX-encoded WKB.""" assert ds is not None, "Error: Missing GDAL dataset" assert level >= 1 - assert len(ulp) == 2 is not None, "Error: invalid upper-left corner" + assert len(ulp) == 2, "Error: invalid upper-left corner" if xsize is None or ysize is None: assert xsize is None and ysize is None diff --git a/raster/scripts/python/rtreader.py b/raster/scripts/python/rtreader.py index 4403be577..f17187d52 100755 --- a/raster/scripts/python/rtreader.py +++ b/raster/scripts/python/rtreader.py @@ -175,7 +175,7 @@ class RasterReader(object): self._sizes = self._query_single_row(sql) if self._sizes is None: - raise RasterError("Falied to query %dx%d of band %d is none" %(x, y, band)) + raise RasterError("Falied to query raster size of dim {} with force {}".format(dim, force)) return self._sizes[dim] def _query_pixel_types(self): -- 2.50.1