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
|
|
@ -2,7 +2,10 @@ from __future__ import annotations
|
|||
|
||||
from asgi_csrf import Errors
|
||||
import asyncio
|
||||
from typing import Any, Dict, Iterable, List
|
||||
from typing import TYPE_CHECKING, Any, Dict, Iterable, List
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from datasette.permissions import AllowedResource, Resource
|
||||
import asgi_csrf
|
||||
import collections
|
||||
import dataclasses
|
||||
|
|
@ -117,8 +120,7 @@ from .tracer import AsgiTracer
|
|||
from .plugins import pm, DEFAULT_PLUGINS, get_plugins
|
||||
from .version import __version__
|
||||
|
||||
from .permissions import PermissionSQL
|
||||
from .resources import InstanceResource, DatabaseResource, TableResource
|
||||
from .resources import DatabaseResource, TableResource
|
||||
|
||||
app_root = Path(__file__).parent.parent
|
||||
|
||||
|
|
@ -1176,7 +1178,6 @@ class Datasette:
|
|||
if table.private:
|
||||
print(f"{table.child} is private")
|
||||
"""
|
||||
from datasette.permissions import Resource
|
||||
|
||||
action_obj = self.actions.get(action)
|
||||
if not action_obj:
|
||||
|
|
@ -1217,7 +1218,7 @@ class Datasette:
|
|||
for allowed in debug_info:
|
||||
print(f"{allowed.resource}: {allowed.reason}")
|
||||
"""
|
||||
from datasette.permissions import AllowedResource, Resource
|
||||
from datasette.permissions import AllowedResource
|
||||
|
||||
action_obj = self.actions.get(action)
|
||||
if not action_obj:
|
||||
|
|
@ -1277,7 +1278,6 @@ class Datasette:
|
|||
"""
|
||||
from datasette.utils.actions_sql import check_permission_for_resource
|
||||
from datasette.resources import InstanceResource
|
||||
import datetime
|
||||
|
||||
if resource is None:
|
||||
resource = InstanceResource()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue