Skip to content

Commit

Permalink
Configured and applied isort, refs #516
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Aug 23, 2023
1 parent 17ec309 commit 59a5d33
Show file tree
Hide file tree
Showing 78 changed files with 435 additions and 352 deletions.
6 changes: 5 additions & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[settings]
multi_line_output=3

include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
known_first_party=datasette
5 changes: 3 additions & 2 deletions datasette/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from datasette.permissions import Permission # noqa
from datasette.version import __version_info__, __version__ # noqa
from datasette.utils.asgi import Forbidden, NotFound, Request, Response # noqa
from datasette.utils import actor_matches_allow # noqa
from datasette.utils.asgi import Forbidden, NotFound, Request, Response # noqa
from datasette.version import __version__, __version_info__ # noqa
from datasette.views import Context # noqa

from .hookspecs import hookimpl # noqa
from .hookspecs import hookspec # noqa
6 changes: 4 additions & 2 deletions datasette/actor_auth_cookie.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from datasette import hookimpl
import time

from itsdangerous import BadSignature

from datasette import hookimpl
from datasette.utils import baseconv
import time


@hookimpl
Expand Down
85 changes: 35 additions & 50 deletions datasette/app.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import asyncio
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
import asgi_csrf
import collections
import dataclasses
import datetime
import functools
import glob
import hashlib
import httpx
import inspect
from itsdangerous import BadSignature
import json
import os
import pkg_resources
import re
import secrets
import sys
Expand All @@ -22,47 +17,25 @@
import urllib.parse
from concurrent import futures
from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union

from markupsafe import Markup, escape
from itsdangerous import URLSafeSerializer
from jinja2 import (
ChoiceLoader,
Environment,
FileSystemLoader,
PrefixLoader,
)
import asgi_csrf
import httpx
import pkg_resources
from itsdangerous import BadSignature, URLSafeSerializer
from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PrefixLoader
from jinja2.environment import Template
from jinja2.exceptions import TemplateNotFound
from markupsafe import Markup, escape

from .views import Context
from .views.base import ureg
from .views.database import database_download, DatabaseView, TableCreateView
from .views.index import IndexView
from .views.special import (
JsonDataView,
PatternPortfolioView,
AuthTokenView,
ApiExplorerView,
CreateTokenView,
LogoutView,
AllowDebugView,
PermissionsDebugView,
MessagesDebugView,
)
from .views.table import (
TableInsertView,
TableUpsertView,
TableDropView,
table_view,
)
from .views.row import RowView, RowDeleteView, RowUpdateView
from .database import Database, QueryInterrupted
from .plugins import DEFAULT_PLUGINS, get_plugins, pm
from .renderer import json_renderer
from .tracer import AsgiTracer
from .url_builder import Urls
from .database import Database, QueryInterrupted

from .utils import (
PrefixedUrlString,
SPATIALITE_FUNCTIONS,
PrefixedUrlString,
StartupError,
async_call_with_supported_arguments,
await_me_maybe,
Expand All @@ -76,34 +49,46 @@
parse_metadata,
resolve_env_secrets,
resolve_routes,
row_sql_params_pks,
tilde_decode,
to_css_class,
urlsafe_components,
row_sql_params_pks,
)
from .utils.asgi import (
AsgiLifespan,
AsgiRunOnFirstRequest,
DatabaseNotFound,
Forbidden,
NotFound,
DatabaseNotFound,
TableNotFound,
RowNotFound,
Request,
Response,
AsgiRunOnFirstRequest,
asgi_static,
RowNotFound,
TableNotFound,
asgi_send,
asgi_send_file,
asgi_send_redirect,
asgi_static,
)
from .utils.internal_db import init_internal_db, populate_schema_tables
from .utils.sqlite import (
sqlite3,
using_pysqlite3,
)
from .tracer import AsgiTracer
from .plugins import pm, DEFAULT_PLUGINS, get_plugins
from .utils.sqlite import sqlite3, using_pysqlite3
from .version import __version__
from .views import Context
from .views.base import ureg
from .views.database import DatabaseView, TableCreateView, database_download
from .views.index import IndexView
from .views.row import RowDeleteView, RowUpdateView, RowView
from .views.special import (
AllowDebugView,
ApiExplorerView,
AuthTokenView,
CreateTokenView,
JsonDataView,
LogoutView,
MessagesDebugView,
PatternPortfolioView,
PermissionsDebugView,
)
from .views.table import TableDropView, TableInsertView, TableUpsertView, table_view

app_root = Path(__file__).parent.parent

Expand Down
5 changes: 3 additions & 2 deletions datasette/blob_renderer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import hashlib

from datasette import hookimpl
from datasette.utils.asgi import Response, BadRequest
from datasette.utils import to_css_class
import hashlib
from datasette.utils.asgi import BadRequest, Response

_BLOB_COLUMN = "_blob_column"
_BLOB_HASH = "_blob_hash"
Expand Down
32 changes: 17 additions & 15 deletions datasette/cli.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import asyncio
import uvicorn
import click
from click import formatting
from click.types import CompositeParamType
from click_default_group import DefaultGroup
import functools
import json
import os
import pathlib
from runpy import run_module
import shutil
from subprocess import call
import sys
import textwrap
import webbrowser
from runpy import run_module
from subprocess import call

import click
import uvicorn
from click import formatting
from click.types import CompositeParamType
from click_default_group import DefaultGroup

from .app import (
OBSOLETE_SETTINGS,
Datasette,
DEFAULT_SETTINGS,
OBSOLETE_SETTINGS,
SETTINGS,
SQLITE_LIMIT_ATTACHED,
Datasette,
pm,
)
from .utils import (
ConnectionProblem,
LoadExtension,
SpatialiteConnectionProblem,
SpatialiteNotFound,
StartupError,
StaticMount,
ValueAsBooleanError,
check_connection,
find_spatialite,
parse_metadata,
ConnectionProblem,
SpatialiteConnectionProblem,
initial_path_for_datasette,
parse_metadata,
temporary_docker_directory,
value_as_boolean,
SpatialiteNotFound,
StaticMount,
ValueAsBooleanError,
)
from .utils.sqlite import sqlite3
from .utils.testing import TestClient
Expand Down
13 changes: 7 additions & 6 deletions datasette/database.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import asyncio
from collections import namedtuple
from pathlib import Path
import hashlib
import janus
import queue
import sys
import threading
import uuid
from collections import namedtuple
from pathlib import Path

import janus

from .inspect import inspect_hash
from .tracer import trace
from .utils import (
detect_fts,
detect_primary_keys,
detect_spatialite,
get_all_foreign_keys,
get_outbound_foreign_keys,
sqlite_timelimit,
sqlite3,
table_columns,
sqlite_timelimit,
table_column_details,
table_columns,
)
from .inspect import inspect_hash

connections = threading.local()

Expand Down
3 changes: 2 additions & 1 deletion datasette/default_magic_parameters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from datasette import hookimpl
import datetime
import os
import time

from datasette import hookimpl


def header(key, request):
key = key.replace("_", "-").encode("utf-8")
Expand Down
8 changes: 5 additions & 3 deletions datasette/default_permissions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from datasette import hookimpl, Permission
from datasette.utils import actor_matches_allow
import itsdangerous
import time

import itsdangerous

from datasette import Permission, hookimpl
from datasette.utils import actor_matches_allow


@hookimpl
def register_permissions():
Expand Down
3 changes: 2 additions & 1 deletion datasette/facets.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import json
import urllib

from datasette import hookimpl
from datasette.database import QueryInterrupted
from datasette.utils import (
detect_json1,
escape_sqlite,
path_with_added_args,
path_with_removed_args,
detect_json1,
sqlite3,
)

Expand Down
8 changes: 5 additions & 3 deletions datasette/filters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from datasette import hookimpl
from datasette.views.base import DatasetteError
from datasette.utils.asgi import BadRequest
import json
import numbers

from datasette import hookimpl
from datasette.utils.asgi import BadRequest
from datasette.views.base import DatasetteError

from .utils import detect_json1, escape_sqlite, path_with_removed_args


Expand Down
3 changes: 2 additions & 1 deletion datasette/forbidden.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from os import stat
from datasette import hookimpl, Response

from datasette import Response, hookimpl


@hookimpl(trylast=True)
Expand Down
16 changes: 8 additions & 8 deletions datasette/handle_exception.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from datasette import hookimpl, Response
from .utils import await_me_maybe, add_cors_headers
from .utils.asgi import (
Base400,
Forbidden,
)
from .views.base import DatasetteError
from markupsafe import Markup
import pdb
import traceback

from markupsafe import Markup

from datasette import Response, hookimpl

from .plugins import pm
from .utils import add_cors_headers, await_me_maybe
from .utils.asgi import Base400, Forbidden
from .views.base import DatasetteError

try:
import rich
Expand Down
3 changes: 1 addition & 2 deletions datasette/hookspecs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pluggy import HookimplMarker
from pluggy import HookspecMarker
from pluggy import HookimplMarker, HookspecMarker

hookspec = HookspecMarker("datasette")
hookimpl = HookimplMarker("datasette")
Expand Down
5 changes: 2 additions & 3 deletions datasette/inspect.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import hashlib

from .utils import (
detect_spatialite,
detect_fts,
detect_primary_keys,
detect_spatialite,
escape_sqlite,
get_all_foreign_keys,
table_columns,
sqlite3,
table_columns,
)


HASH_BLOCK_SIZE = 1024 * 1024


Expand Down
6 changes: 4 additions & 2 deletions datasette/plugins.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import importlib
import pluggy
import pkg_resources
import sys

import pkg_resources
import pluggy

from . import hookspecs

DEFAULT_PLUGINS = (
Expand Down
Loading

0 comments on commit 59a5d33

Please sign in to comment.