Skip to content

Database() arguments after path are keyword-only, document mode= - #3109

Merged
simonw merged 1 commit into
mainfrom
database-constructor-keyword-only
Nov 22, 2026
Merged

simonw merged 1 commit into
mainfrom
database-constructor-keyword-only

Conversation

@simonw

@simonw simonw commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Refs:

Every argument to the Database() constructor after path is now keyword-only:

Database(ds, path=None, *, is_mutable=True, is_memory=False, memory_name=None, mode=None, is_temp_disk=False)
Claude Fable 5.2 High

The documented signature left out mode, which sits before is_temp_disk. A plugin that passed is_temp_disk by position, as documented, set mode instead.

Changes

  • datasette/database.py: adds the * after path. Nothing in Datasette or its tests passed these arguments by position.
  • docs/internals.rst: the heading now shows the real signature, mode is documented, and a short example replaces the sentence describing the argument order.
  • docs/changelog.rst: one line added to the existing list of keyword-only signatures.

Backwards incompatible: code that passes is_mutable, is_memory, memory_name, mode or is_temp_disk by position now gets a TypeError. The argument names have not changed, so passing them by keyword works with earlier versions too.

Tests

Two new tests in tests/test_internals_database.py: one that positional arguments after path raise TypeError, and one that mode="rwc" creates a file that does not exist yet. The first fails without the change. The full suite passes locally (3,652 passed).

🤖 Generated with Claude Code

The documented signature left out the mode argument, which sits before
is_temp_disk, so passing is_temp_disk by position as documented set
mode instead.

Refs #2942, refs #1822

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (ea8d80f) to head (e9e291b).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3109   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         81      81           
  Lines      14582   14582           
=====================================
  Misses     14582   14582           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@simonw
simonw merged commit 9f2da6b into main Nov 22, 2026
16 checks passed
@simonw
simonw deleted the database-constructor-keyword-only branch November 22, 2026 22:01
@simonw simonw added this to the Datasette 1.0 stable milestone Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant