mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fix type annotation bugs and remove unused imports
This fixes issues introduced by the ruff commit e57f391a which converted Optional[x] to x | None: - Fixed datasette/app.py line 1024: Dict[id | str, Dict] -> Dict[int | str, Dict] (was using id built-in function instead of int type) - Fixed datasette/app.py line 1074: Optional["Resource"] -> "Resource" | None - Added 'from __future__ import annotations' for Python 3.10 compatibility - Added TYPE_CHECKING blocks to avoid circular imports - Removed dead code (unused variable assignments) from cli.py and views - Removed unused imports flagged by ruff across multiple files - Fixed test fixtures: moved app_client fixture imports to conftest.py (fixed 71 test errors caused by fixtures not being registered) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
2c8e92acf2
commit
5c537e0a3e
24 changed files with 45 additions and 31 deletions
|
|
@ -231,3 +231,27 @@ def ds_unix_domain_socket_server(tmp_path_factory):
|
|||
yield ds_proc, uds
|
||||
# Shut it down at the end of the pytest session
|
||||
ds_proc.terminate()
|
||||
|
||||
|
||||
# Import fixtures from fixtures.py to make them available
|
||||
from .fixtures import ( # noqa: E402, F401
|
||||
app_client,
|
||||
app_client_base_url_prefix,
|
||||
app_client_conflicting_database_names,
|
||||
app_client_csv_max_mb_one,
|
||||
app_client_immutable_and_inspect_file,
|
||||
app_client_larger_cache_size,
|
||||
app_client_no_files,
|
||||
app_client_returned_rows_matches_page_size,
|
||||
app_client_shorter_time_limit,
|
||||
app_client_two_attached_databases,
|
||||
app_client_two_attached_databases_crossdb_enabled,
|
||||
app_client_two_attached_databases_one_immutable,
|
||||
app_client_with_cors,
|
||||
app_client_with_dot,
|
||||
app_client_with_trace,
|
||||
generate_compound_rows,
|
||||
generate_sortable_rows,
|
||||
make_app_client,
|
||||
TEMP_PLUGIN_SECRET_FILE,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from datasette.app import Datasette
|
||||
from datasette.plugins import DEFAULT_PLUGINS
|
||||
from datasette.utils.sqlite import supports_table_xinfo
|
||||
from datasette.version import __version__
|
||||
from .fixtures import ( # noqa
|
||||
app_client,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from bs4 import BeautifulSoup as Soup
|
||||
from .fixtures import app_client
|
||||
from .utils import cookie_was_deleted, last_event
|
||||
from click.testing import CliRunner
|
||||
from datasette.utils import baseconv
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from bs4 import BeautifulSoup as Soup
|
|||
import json
|
||||
import pytest
|
||||
import re
|
||||
from .fixtures import make_app_client, app_client
|
||||
from .fixtures import make_app_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from .fixtures import (
|
||||
app_client,
|
||||
make_app_client,
|
||||
TestClient as _TestClient,
|
||||
EXPECTED_PLUGINS,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from datasette.cli import cli
|
|||
from click.testing import CliRunner
|
||||
import urllib
|
||||
import sqlite3
|
||||
from .fixtures import app_client_two_attached_databases_crossdb_enabled
|
||||
|
||||
|
||||
def test_crossdb_join(app_client_two_attached_databases_crossdb_enabled):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
from asgi_csrf import Errors
|
||||
from bs4 import BeautifulSoup as Soup
|
||||
from datasette.app import Datasette
|
||||
from datasette.utils import allowed_pragmas
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from datasette.app import Datasette
|
|||
from datasette.database import Database, Results, MultipleValues
|
||||
from datasette.utils.sqlite import sqlite3, sqlite_version
|
||||
from datasette.utils import Column
|
||||
from .fixtures import app_client, app_client_two_attached_databases_crossdb_enabled
|
||||
import pytest
|
||||
import time
|
||||
import uuid
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Tests for the datasette.app.Datasette class
|
|||
"""
|
||||
|
||||
import dataclasses
|
||||
from datasette import Forbidden, Context
|
||||
from datasette import Context
|
||||
from datasette.app import Datasette, Database
|
||||
from datasette.resources import DatabaseResource
|
||||
from itsdangerous import BadSignature
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from bs4 import BeautifulSoup as Soup
|
||||
from .fixtures import (
|
||||
app_client,
|
||||
make_app_client,
|
||||
TABLES,
|
||||
TEMP_PLUGIN_SECRET_FILE,
|
||||
|
|
@ -9,7 +8,7 @@ from .fixtures import (
|
|||
) # noqa
|
||||
from click.testing import CliRunner
|
||||
from datasette.app import Datasette
|
||||
from datasette import cli, hookimpl, Permission
|
||||
from datasette import cli, hookimpl
|
||||
from datasette.filters import FilterArguments
|
||||
from datasette.plugins import get_plugins, DEFAULT_PLUGINS, pm
|
||||
from datasette.permissions import PermissionSQL
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from .fixtures import ( # noqa
|
|||
import pathlib
|
||||
import pytest
|
||||
import urllib.parse
|
||||
from .utils import assert_footer_links, inner_html
|
||||
from .utils import inner_html
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue