From 5b822492c884c9b7c366f7d02c685eb1b7efc976 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Sun, 10 Apr 2016 22:49:08 -0700 Subject: [PATCH] Linting to 99% (#317) --- caravel/migrations/versions/d2424a248d63_.py | 3 --- caravel/migrations/versions/fee7b758c130_.py | 3 --- caravel/models.py | 6 +++--- caravel/views.py | 4 ++-- caravel/viz.py | 6 ++++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/caravel/migrations/versions/d2424a248d63_.py b/caravel/migrations/versions/d2424a248d63_.py index e50d21f0be8de..fdfabc9166c21 100644 --- a/caravel/migrations/versions/d2424a248d63_.py +++ b/caravel/migrations/versions/d2424a248d63_.py @@ -10,9 +10,6 @@ revision = 'd2424a248d63' down_revision = ('a2d606a761d9', '836c0bf75904') -from alembic import op -import sqlalchemy as sa - def upgrade(): pass diff --git a/caravel/migrations/versions/fee7b758c130_.py b/caravel/migrations/versions/fee7b758c130_.py index 1bd72d7e1410c..28b05b17e3e7d 100644 --- a/caravel/migrations/versions/fee7b758c130_.py +++ b/caravel/migrations/versions/fee7b758c130_.py @@ -10,9 +10,6 @@ revision = 'fee7b758c130' down_revision = ('1d2ddd543133', '763d4b211ec9') -from alembic import op -import sqlalchemy as sa - def upgrade(): pass diff --git a/caravel/models.py b/caravel/models.py index ecf712a42c05a..3588d13e1c079 100644 --- a/caravel/models.py +++ b/caravel/models.py @@ -55,18 +55,18 @@ class AuditMixinNullable(AuditMixin): onupdate=datetime.now, nullable=True) @declared_attr - def created_by_fk(cls): + def created_by_fk(cls): # noqa return Column(Integer, ForeignKey('ab_user.id'), default=cls.get_user_id, nullable=True) @declared_attr - def changed_by_fk(cls): + def changed_by_fk(cls): # noqa return Column( Integer, ForeignKey('ab_user.id'), default=cls.get_user_id, onupdate=cls.get_user_id, nullable=True) @property - def created_by_(self): + def created_by_(self): # noqa return '{}'.format(self.created_by or '') @property # noqa diff --git a/caravel/views.py b/caravel/views.py index 738f80f9d50d3..1c55b6944f629 100644 --- a/caravel/views.py +++ b/caravel/views.py @@ -478,7 +478,7 @@ def explore(self, datasource_type, datasource_id): obj = viz.viz_types[viz_type]( datasource, form_data=request.args, - slice=slc) + slice_=slc) if request.args.get("json") == "true": status = 200 try: @@ -642,7 +642,7 @@ def testconn(self): @expose("/favstar////") def favstar(self, class_name, obj_id, action): session = db.session() - FavStar = models.FavStar + FavStar = models.FavStar # noqa count = 0 favs = session.query(FavStar).filter_by( class_name=class_name, obj_id=obj_id, user_id=g.user.id).all() diff --git a/caravel/viz.py b/caravel/viz.py index ed039cf9ce922..75381d7de473a 100644 --- a/caravel/viz.py +++ b/caravel/viz.py @@ -46,14 +46,14 @@ class BaseViz(object): },) form_overrides = {} - def __init__(self, datasource, form_data, slice=None): + def __init__(self, datasource, form_data, slice_=None): self.orig_form_data = form_data if not datasource: raise Exception("Viz is missing a datasource") self.datasource = datasource self.request = request self.viz_type = form_data.get("viz_type") - self.slice = slice + self.slice = slice_ # TODO refactor all form related logic out of here and into forms.py ff = FormFactory(self) @@ -1170,12 +1170,14 @@ def get_data(self): def find_cycle(g): """Whether there's a cycle in a directed graph""" path = set() + def visit(vertex): path.add(vertex) for neighbour in g.get(vertex, ()): if neighbour in path or visit(neighbour): return (vertex, neighbour) path.remove(vertex) + for v in g: cycle = visit(v) if cycle: