Skip to content

declare the public members BaseDatabaseWrapper was missing - #413

Merged
kodiakhq[bot] merged 3 commits into
sbdchd:mainfrom
NorthIsUp:database-wrapper-attrs
Sep 26, 2026
Merged

kodiakhq[bot] merged 3 commits into
sbdchd:mainfrom
NorthIsUp:database-wrapper-attrs

Conversation

@NorthIsUp

@NorthIsUp NorthIsUp commented Sep 25, 2026 •

Copy link
Copy Markdown

BaseDatabaseWrapper was missing nine of its public members from the stub. These are the ones that exist on the class in Django 6.0.8 but weren't declared:

Member What it is
atomic_blocks set to [] in __init__; transaction.atomic() pushes Atomic instances onto it
rollback_exc the exception that marked the transaction for rollback, or None
health_check_enabled, health_check_done booleans set in __init__
inc_thread_sharing(), dec_thread_sharing() the counters behind allow_thread_sharing
close_if_health_check_failed() returns nothing
get_database_version() abstract on the base class; every backend returns a tuple of ints
check_database_version_supported() raises NotSupportedError if the server is too old

I found the first three through code that hands a connection to another thread. The rest turned up when I compared the stub against everything the class defines, so this closes the class out rather than patching one gap at a time.

tests/pyright/test_database_wrapper.py covers all nine and fails without the stub change. It doesn't touch the same files as #407, so the two can land in either order.

…ters

atomic_blocks is set in __init__ and inc_thread_sharing/dec_thread_sharing
are public methods; code that hands a connection to another thread (test
helpers, mostly) couldn't reference them.
get_database_version, check_database_version_supported,
close_if_health_check_failed, health_check_enabled, health_check_done and
rollback_exc were missing too. The class now declares everything public
that Django 6.0 defines on it.
@NorthIsUp NorthIsUp changed the title declare BaseDatabaseWrapper.atomic_blocks and the thread-sharing counters declare the public members BaseDatabaseWrapper was missing Sep 25, 2026

@sbdchd sbdchd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kodiakhq
kodiakhq Bot merged commit a13d28a into sbdchd:main Sep 26, 2026
2 checks passed
sobolevn pushed a commit to typeddjango/django-stubs that referenced this pull request Oct 23, 2026
…butes (#3725)

# I have made things!

`BaseDatabaseWrapper.__init__` sets `rollback_exc`, `health_check_enabled` and `health_check_done`, but the stub didn't declare them.

## Related issues
Ported from sbdchd#413

## AI Policy
- [ ] I have read and agree to the [AI Policy](https://github.com/typeddjango/django-stubs/blob/master/.github/AI_POLICY.md), removed any "Co-Authored-By" lines attributing coding agents, and manually reviewed the final result
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.

2 participants