Cleaned up pylint warnings

This commit is contained in:
Simon Willison 2019-04-13 12:20:10 -07:00
commit d1075b8259
4 changed files with 13 additions and 3 deletions

View file

@ -348,6 +348,7 @@ class Datasette:
conn.execute("SELECT load_extension('{}')".format(extension))
if self.config("cache_size_kb"):
conn.execute('PRAGMA cache_size=-{}'.format(self.config("cache_size_kb")))
# pylint: disable=no-member
pm.hook.prepare_connection(conn=conn)
async def table_exists(self, database, table):
@ -467,7 +468,7 @@ class Datasette:
sqlite_extensions[extension] = result.fetchone()[0]
else:
sqlite_extensions[extension] = None
except Exception as e:
except Exception:
pass
# Figure out supported FTS versions
fts_versions = []
@ -649,6 +650,7 @@ class Datasette:
self.jinja_env.filters["quote_plus"] = lambda u: urllib.parse.quote_plus(u)
self.jinja_env.filters["escape_sqlite"] = escape_sqlite
self.jinja_env.filters["to_css_class"] = to_css_class
# pylint: disable=no-member
pm.hook.prepare_jinja2_environment(env=self.jinja_env)
app.add_route(IndexView.as_view(self), r"/<as_format:(\.jsono?)?$>")
# TODO: /favicon.ico and /-/static/ deserve far-future cache expires
@ -697,6 +699,7 @@ class Datasette:
)
self.register_custom_units()
# On 404 with a trailing slash redirect to path without that slash:
# pylint: disable=unused-variable
@app.middleware("response")
def redirect_on_404_with_trailing_slash(request, original_response):
if original_response.status == 404 and request.path.endswith("/"):

View file

@ -5,6 +5,7 @@ from . import hookspecs
DEFAULT_PLUGINS = (
"datasette.publish.heroku",
"datasette.publish.now",
"datasette.facets",
)
pm = pluggy.PluginManager("datasette")

View file

@ -94,6 +94,7 @@ class RenderMixin(HTTPMethodView):
for template_name in templates
]
body_scripts = []
# pylint: disable=no-member
for script in pm.hook.extra_body_script(
template=template.name,
database=context.get("database"),
@ -148,6 +149,9 @@ class BaseView(RenderMixin):
r.headers["Access-Control-Allow-Origin"] = "*"
return r
async def data(self, request, database, hash, **kwargs):
raise NotImplementedError
async def resolve_db_name(self, request, db_name, **kwargs):
hash = None
name = None
@ -238,7 +242,7 @@ class BaseView(RenderMixin):
if isinstance(response_or_template_contexts, response.HTTPResponse):
return response_or_template_contexts
else:
data, extra_template_data, templates = response_or_template_contexts
data, _, _ = response_or_template_contexts
except (sqlite3.OperationalError, InvalidSql) as e:
raise DatasetteError(str(e), title="Invalid SQL", status=400)
@ -269,7 +273,7 @@ class BaseView(RenderMixin):
if next:
kwargs["_next"] = next
if not first:
data, extra_template_data, templates = await self.data(
data, _, _ = await self.data(
request, database, hash, **kwargs
)
if first:
@ -565,6 +569,7 @@ class BaseView(RenderMixin):
for column, value in zip(results.columns, row):
display_value = value
# Let the plugins have a go
# pylint: disable=no-member
plugin_value = pm.hook.render_cell(
value=value,
column=column,

View file

@ -108,6 +108,7 @@ class RowTableShared(BaseView):
continue
# First let the plugins have a go
# pylint: disable=no-member
plugin_display_value = pm.hook.render_cell(
value=value,
column=column,