From e4f549301b1b6d8066d1949bb2f87ecb83b7e96d Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 25 Oct 2025 14:50:10 -0700 Subject: [PATCH] Remove stale self.permissions dictionary and get_permission() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The self.permissions dictionary was declared in __init__ but never populated - only self.actions gets populated during startup. The get_permission() method was unused legacy code that tried to look up permissions from the empty self.permissions dictionary. Changes: - Removed self.permissions = {} from Datasette.__init__ - Removed get_permission() method (unused) - Renamed test_get_permission → test_get_action to match actual method being tested All tests pass, confirming these were unused artifacts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- datasette/app.py | 15 --------------- tests/test_internals_datasette.py | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/datasette/app.py b/datasette/app.py index 257b9204..21521ab2 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -322,7 +322,6 @@ class Datasette: self.inspect_data = inspect_data self.immutables = set(immutables or []) self.databases = collections.OrderedDict() - self.permissions = {} # .invoke_startup() will populate this self.actions = {} # .invoke_startup() will populate this try: self._refresh_schemas_lock = asyncio.Lock() @@ -546,20 +545,6 @@ class Datasette: pass return environment - def get_permission(self, name_or_abbr: str) -> "Permission": - """ - Returns a Permission object for the given name or abbreviation. Raises KeyError if not found. - """ - if name_or_abbr in self.permissions: - return self.permissions[name_or_abbr] - # Try abbreviation - for permission in self.permissions.values(): - if permission.abbr == name_or_abbr: - return permission - raise KeyError( - "No permission found with name or abbreviation {}".format(name_or_abbr) - ) - def get_action(self, name_or_abbr: str): """ Returns an Action object for the given name or abbreviation. Returns None if not found. diff --git a/tests/test_internals_datasette.py b/tests/test_internals_datasette.py index 9990db04..136385d7 100644 --- a/tests/test_internals_datasette.py +++ b/tests/test_internals_datasette.py @@ -161,7 +161,7 @@ def test_datasette_error_if_string_not_list(tmpdir): @pytest.mark.asyncio -async def test_get_permission(ds_client): +async def test_get_action(ds_client): ds = ds_client.ds for name_or_abbr in ("vi", "view-instance", "vt", "view-table"): action = ds.get_action(name_or_abbr)