mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Modernize code to Python 3.6+ (#1158)
* Compact dict and set building * Remove redundant parentheses * Simplify chained conditions * Change method name to lowercase * Use triple double quotes for docstrings Thanks, @eumiro!
This commit is contained in:
parent
90eba4c3ca
commit
a882d67962
19 changed files with 76 additions and 82 deletions
|
|
@ -74,7 +74,7 @@ class BaseView:
|
|||
raise Forbidden(action)
|
||||
|
||||
async def check_permissions(self, request, permissions):
|
||||
"permissions is a list of (action, resource) tuples or 'action' strings"
|
||||
"""permissions is a list of (action, resource) tuples or 'action' strings"""
|
||||
for permission in permissions:
|
||||
if isinstance(permission, str):
|
||||
action = permission
|
||||
|
|
@ -280,7 +280,7 @@ class DataView(BaseView):
|
|||
except (sqlite3.OperationalError, InvalidSql) as e:
|
||||
raise DatasetteError(str(e), title="Invalid SQL", status=400)
|
||||
|
||||
except (sqlite3.OperationalError) as e:
|
||||
except sqlite3.OperationalError as e:
|
||||
raise DatasetteError(str(e))
|
||||
|
||||
except DatasetteError:
|
||||
|
|
@ -451,7 +451,7 @@ class DataView(BaseView):
|
|||
except (sqlite3.OperationalError, InvalidSql) as e:
|
||||
raise DatasetteError(str(e), title="Invalid SQL", status=400)
|
||||
|
||||
except (sqlite3.OperationalError) as e:
|
||||
except sqlite3.OperationalError as e:
|
||||
raise DatasetteError(str(e))
|
||||
|
||||
except DatasetteError:
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class RowTableShared(DataView):
|
|||
async def display_columns_and_rows(
|
||||
self, database, table, description, rows, link_column=False, truncate_cells=0
|
||||
):
|
||||
"Returns columns, rows for specified table - including fancy foreign key treatment"
|
||||
"""Returns columns, rows for specified table - including fancy foreign key treatment"""
|
||||
db = self.ds.databases[database]
|
||||
table_metadata = self.ds.table_metadata(database, table)
|
||||
column_details = {col.name: col for col in await db.table_column_details(table)}
|
||||
|
|
@ -743,7 +743,7 @@ class TableView(RowTableShared):
|
|||
# Pagination next link
|
||||
next_value = None
|
||||
next_url = None
|
||||
if len(rows) > page_size and page_size > 0:
|
||||
if 0 < page_size < len(rows):
|
||||
if is_view:
|
||||
next_value = int(_next or 0) + page_size
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue