mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Remove stale self.permissions dictionary and get_permission() method
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 <noreply@anthropic.com>
This commit is contained in:
parent
deb0b87e1b
commit
e4f549301b
2 changed files with 1 additions and 16 deletions
|
|
@ -322,7 +322,6 @@ class Datasette:
|
||||||
self.inspect_data = inspect_data
|
self.inspect_data = inspect_data
|
||||||
self.immutables = set(immutables or [])
|
self.immutables = set(immutables or [])
|
||||||
self.databases = collections.OrderedDict()
|
self.databases = collections.OrderedDict()
|
||||||
self.permissions = {} # .invoke_startup() will populate this
|
|
||||||
self.actions = {} # .invoke_startup() will populate this
|
self.actions = {} # .invoke_startup() will populate this
|
||||||
try:
|
try:
|
||||||
self._refresh_schemas_lock = asyncio.Lock()
|
self._refresh_schemas_lock = asyncio.Lock()
|
||||||
|
|
@ -546,20 +545,6 @@ class Datasette:
|
||||||
pass
|
pass
|
||||||
return environment
|
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):
|
def get_action(self, name_or_abbr: str):
|
||||||
"""
|
"""
|
||||||
Returns an Action object for the given name or abbreviation. Returns None if not found.
|
Returns an Action object for the given name or abbreviation. Returns None if not found.
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ def test_datasette_error_if_string_not_list(tmpdir):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_get_permission(ds_client):
|
async def test_get_action(ds_client):
|
||||||
ds = ds_client.ds
|
ds = ds_client.ds
|
||||||
for name_or_abbr in ("vi", "view-instance", "vt", "view-table"):
|
for name_or_abbr in ("vi", "view-instance", "vt", "view-table"):
|
||||||
action = ds.get_action(name_or_abbr)
|
action = ds.get_action(name_or_abbr)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue