Repository navigation
feat!: declare models by overriding accessors, not by dunder - #32
Merged
Merged
Conversation
Breaking, following rhosocial-activerecord: model fixtures now override table_name(), primary_key(), pk_auto_generated(), read_only() and the locator methods instead of assigning __table_name__ and friends, and the composite-key contract tests assert pk_auto_generated() rather than the removed attribute. 534 declarations across 55 files, produced by the core repository\x27s declaration sweep so both sides stay byte-identical in shape.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Follows rhosocial/python-activerecord#140, which makes a model declare its table name, key, locators and read-only-ness by overriding an accessor classmethod instead of assigning a class-body dunder. This shared test suite is where nearly every model in the ecosystem is defined, so its fixtures declared
__table_name__,__primary_key__,__pk_auto_generated__and the locator dunders throughout — declarations the released core no longer reads.Every one of them was rewritten to the accessor form in a single mechanical change:
__table_name__→table_name(),__primary_key__→primary_key(),__pk_auto_generated__→pk_auto_generated(),read_only()whereReadOnlyMixinused to be opted out of with a dunder.order_item_class.__pk_auto_generated__ is Falsebecamepk_auto_generated() is False, in both the sync and async composite-key suites.The sweep is AST-located rather than regex-matched, preserves line endings and spacing, and handles the
type(...)namespace-dict form separately from class bodies. No new lint findings: the total drops where the removed assignments took their imports with them.Type of change
feat: A new featuretest: Adding missing tests or correcting existing tests (for the new feature)ci: Changes to our CI configuration files and scripts (if related to the new feature)docs: Documentation only changes (if related to the new feature)perf: A code change that improves performance (if part of the feature)chore: Changes to the build process or auxiliary tools and libraries suchs as documentation generation (if related to the new feature)build: Changes that affect the build system or external dependencies (if related to the new feature)revert: Reverts a previous commitBreaking Change
Impact on End-Users:
N/A: this repository is a test-suite library, installed into the backends' virtual environments. Its published API is the fixtures and the provider contracts, and those keep their names; only the declaration spelling inside them changed.
Impact on Backend Developers (Custom Implementations):
A backend that provides models or fixtures of its own must declare them through the accessors as well —
__table_name__and friends are no longer read, and a model with notable_name()override now fails withNotImplementedErrorat the first read.Related Repositories/Packages
rhosocial/python-activerecord— PR #140, merged intorelease/v1.0.0.dev30.feature/declaration-surfacePR that installs this branch fromtest.yml. This PR must merge first: until it does, those workflows cannot point atrelease/v1.0.0.dev17, because that branch still declares the removed dunders.Merge order: this PR → the backend PRs (whose
test.ymltestsuite ref is then updated from the branch to the release branch).Testing
Test Plan:
This repository has no test workflow of its own (it is a library that gets installed into other repositories). Its verification is the downstream runs: core's full Python matrix (3.8–3.15t, coverage, benchmarks) and the nine backend matrices all executed against this branch and passed — that is 12,000+ tests in core plus each backend's own version × database matrix.
Checklist
README.md, etc.).changelog.d/<issue_number>.<type>.md).Additional Notes
The same migration sweep is applied to every repository in the family, so the fixtures here and the models in the backends stay identical in shape. Migration tooling lives in core's
scripts/.