Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add pep8 validation to Travis build process #40

Merged
merged 4 commits into from

2 participants

@Turbo87
Owner

see #38

Turbo87 added some commits
@Turbo87 Turbo87 functions: Fixed PEP8 warnings
E501 line too long
27931d6
@Turbo87 Turbo87 tests: Fixed PEP8 warnings 51693a6
@Turbo87 Turbo87 TravisCI: Added flake8 checking
E711 is ignored because "is None" does not work in SQLAlchemy's filter()
method, but flake8 warns that "== None" should not be used.
7b1050b
@Turbo87
Owner

feel free to merge :)

@Turbo87
Owner

or not... thanks TravisCI!

@Turbo87 Turbo87 shape: Fixed buffer usage for Python 3.x
This is theoretically irrelevant since shapely is not yet compatible
with Python 3.x, but flake8 is complaining on Python 3.x that buffer is
not defined.
bdf9b78
@elemoine
Owner

Thanks!

@elemoine elemoine merged commit b1ac588 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 1, 2013
  1. @Turbo87

    functions: Fixed PEP8 warnings

    Turbo87 authored
    E501 line too long
  2. @Turbo87

    tests: Fixed PEP8 warnings

    Turbo87 authored
  3. @Turbo87

    TravisCI: Added flake8 checking

    Turbo87 authored
    E711 is ignored because "is None" does not work in SQLAlchemy's filter()
    method, but flake8 warns that "== None" should not be used.
  4. @Turbo87

    shape: Fixed buffer usage for Python 3.x

    Turbo87 authored
    This is theoretically irrelevant since shapely is not yet compatible
    with Python 3.x, but flake8 is complaining on Python 3.x that buffer is
    not defined.
This page is out of date. Refresh to see the latest.
View
6 .travis.yml
@@ -31,6 +31,9 @@ install:
- if [[ "$POSTGIS_VERSION" != "1.5" ]]; then sudo make install; fi
- if [[ "$POSTGIS_VERSION" != "1.5" ]]; then cd ..; fi
+ # Install flake8 style checker
+ - pip install flake8
+
before_script:
# Create database user "gis"
- psql -c "CREATE ROLE gis PASSWORD 'gis' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;" -U postgres
@@ -44,6 +47,9 @@ before_script:
- if [[ "$POSTGIS_VERSION" != "1.5" ]]; then psql -d gis -U postgres -c "CREATE EXTENSION postgis;"; fi
script:
+ # Run the library through flake8
+ - flake8 geoalchemy2 --ignore=E711
+
# Run the unit test suite
- python setup.py nosetests -v
View
19 geoalchemy2/functions.py
@@ -167,20 +167,21 @@ def __init__(self, *args, **kwargs):
#
('ST_Area', None,
- 'Returns the area of the surface if it is a polygon or multi-polygon. For '
- '``geometry`` type area is in SRID units. For ``geography`` area is in '
- 'square meters.'),
+ 'Returns the area of the surface if it is a polygon or multi-polygon. '
+ 'For ``geometry`` type area is in SRID units. For ``geography`` area is '
+ 'in square meters.'),
('ST_Centroid', types.Geometry,
'Returns the geometric center of a geometry.'),
('ST_Contains', None,
- 'Returns true if and only if no points of B lie in the exterior of A, and '
- 'at least one point of the interior of B lies in the interior of A.'),
+ 'Returns true if and only if no points of B lie in the exterior of A, '
+ 'and at least one point of the interior of B lies in the interior of A.'),
('ST_ContainsProperly', None,
- 'Returns true if B intersects the interior of A but not the boundary (or '
- 'exterior). A does not contain properly itself, but does contain itself.'),
+ 'Returns true if B intersects the interior of A but not the boundary '
+ '(or exterior). A does not contain properly itself, but does contain '
+ 'itself.'),
('ST_Covers', None,
'Returns 1 (TRUE) if no point in Geometry B is outside Geometry A'),
@@ -262,8 +263,8 @@ def __init__(self, *args, **kwargs):
'relates the 2 geometries.'),
('ST_Touches', None,
- 'Returns ``TRUE`` if the geometries have at least one point in common, but '
- 'their interiors do not intersect.'),
+ 'Returns ``TRUE`` if the geometries have at least one point in common, '
+ 'but their interiors do not intersect.'),
('ST_Within', None,
'Returns ``TRUE`` if the geometry A is completely inside geometry B'),
View
6 geoalchemy2/shape.py
@@ -2,11 +2,17 @@
This module provides utility functions for integrating with Shapely.
"""
+import sys
+
import shapely.wkb
import shapely.wkt
from .elements import WKBElement, WKTElement
+# Backwards compatibility for Python 3.x
+if sys.version_info[0] != 2:
+ buffer = memoryview
+
def to_shape(element):
"""
View
4 geoalchemy2/tests/test_comparator.py
@@ -113,7 +113,7 @@ def test_distance_centroid(self):
expr = table.c.geom.distance_centroid('POINT(1 2)')
eq_sql(expr, '"table".geom <-> ST_GeomFromText(:geom_1)')
s = table.select().order_by(
- table.c.geom.distance_centroid('POINT(1 2)')).limit(10)
+ table.c.geom.distance_centroid('POINT(1 2)')).limit(10)
eq_sql(s, 'SELECT ST_AsBinary("table".geom) AS geom '
'FROM "table" '
'ORDER BY "table".geom <-> ST_GeomFromText(:geom_1) '
@@ -125,7 +125,7 @@ def test_distance_box(self):
expr = table.c.geom.distance_box('POINT(1 2)')
eq_sql(expr, '"table".geom <#> ST_GeomFromText(:geom_1)')
s = table.select().order_by(
- table.c.geom.distance_box('POINT(1 2)')).limit(10)
+ table.c.geom.distance_box('POINT(1 2)')).limit(10)
eq_sql(s, 'SELECT ST_AsBinary("table".geom) AS geom '
'FROM "table" '
'ORDER BY "table".geom <#> ST_GeomFromText(:geom_1) '
View
6 geoalchemy2/tests/test_elements.py
@@ -28,9 +28,9 @@ def test_function_call(self):
from geoalchemy2.elements import WKBElement
e = WKBElement(b'\x01\x02')
f = e.ST_Buffer(2)
- eq_sql(f,
- 'ST_Buffer(ST_GeomFromWKB(:ST_GeomFromWKB_1, :ST_GeomFromWKB_2), '
- ':param_1)')
+ eq_sql(f, 'ST_Buffer('
+ 'ST_GeomFromWKB(:ST_GeomFromWKB_1, :ST_GeomFromWKB_2), '
+ ':param_1)')
eq_(f.compile().params,
{u'param_1': 2, u'ST_GeomFromWKB_1': b'\x01\x02',
u'ST_GeomFromWKB_2': -1})
View
8 geoalchemy2/tests/test_functional.py
@@ -149,8 +149,8 @@ def test_ST_Buffer(self):
ok_(r1.data == r2.data == r3.data)
r4 = session.query(Lake).filter(
- func.ST_Within(WKTElement('POINT(0 0)', srid=4326),
- Lake.geom.ST_Buffer(2))).one()
+ func.ST_Within(WKTElement('POINT(0 0)', srid=4326),
+ Lake.geom.ST_Buffer(2))).one()
ok_(isinstance(r4, Lake))
eq_(r4.id, lake_id)
@@ -159,8 +159,8 @@ def test_ST_Buffer_Mixed_SRID(self):
from sqlalchemy.sql import func
self._create_one()
session.query(Lake).filter(
- func.ST_Within('POINT(0 0)',
- Lake.geom.ST_Buffer(2))).one()
+ func.ST_Within('POINT(0 0)',
+ Lake.geom.ST_Buffer(2))).one()
class ReflectionTest(unittest.TestCase):
View
8 geoalchemy2/tests/test_functions.py
@@ -19,14 +19,14 @@ def eq_sql(a, b, msg=None):
def _test_simple_func(name):
eq_sql(getattr(func, name)(1).select(),
- 'SELECT %(name)s(:param_1) AS "%(name)s_1"' % \
- dict(name=name))
+ 'SELECT %(name)s(:param_1) AS "%(name)s_1"' %
+ dict(name=name))
def _test_geometry_returning_func(name):
eq_sql(getattr(func, name)(1).select(),
- 'SELECT ST_AsBinary(%(name)s(:param_1)) AS "%(name)s_1"' % \
- dict(name=name))
+ 'SELECT ST_AsBinary(%(name)s(:param_1)) AS "%(name)s_1"' %
+ dict(name=name))
def test_ST_Envelope():
View
6 geoalchemy2/tests/test_shape.py
@@ -1,6 +1,12 @@
+import sys
+
from nose.tools import ok_, eq_
from nose.plugins.skip import SkipTest
+# Backwards compatibility for Python 3.x
+if sys.version_info[0] != 2:
+ buffer = memoryview
+
def test_to_shape_WKBElement():
from geoalchemy2.elements import WKBElement
View
6 geoalchemy2/tests/test_types.py
@@ -198,9 +198,9 @@ def test_ST_Equal_WKTElement_WKTElement(self):
from geoalchemy2.elements import WKTElement
expr = func.ST_Equals(WKTElement('POINT(1 2)'),
WKTElement('POINT(1 2)'))
- eq_sql(expr,
- 'ST_Equals(ST_GeomFromText(:ST_GeomFromText_1, :ST_GeomFromText_2),'
- ' ST_GeomFromText(:ST_GeomFromText_3, :ST_GeomFromText_4))')
+ eq_sql(expr, 'ST_Equals('
+ 'ST_GeomFromText(:ST_GeomFromText_1, :ST_GeomFromText_2), '
+ 'ST_GeomFromText(:ST_GeomFromText_3, :ST_GeomFromText_4))')
eq_(expr.compile().params,
{u'ST_GeomFromText_1': 'POINT(1 2)',
u'ST_GeomFromText_2': -1,
Something went wrong with that request. Please try again.