Skip to content

Add check_constraints() helper for constraint checking#997

Merged
LeMyst merged 2 commits into
masterfrom
issue-154
Jul 4, 2026
Merged

Add check_constraints() helper for constraint checking#997
LeMyst merged 2 commits into
masterfrom
issue-154

Conversation

@LeMyst

@LeMyst LeMyst commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds wbi_helpers.check_constraints(), a thin wrapper around the wbcheckconstraints API action provided by the WikibaseQualityConstraints extension.
  • Unlike the plnode-based approach originally discussed on the issue (which hardcodes Wikidata-specific constraints), this relies entirely on the constraints configured on the target Wikibase instance itself, so it works the same way against Wikidata or any third-party Wikibase installation that has the extension enabled.
  • Accepts one or more entity_id and/or claim_id, plus an optional status filter (e.g. violation, warning), letting callers check constraints for a whole entity or for a specific claim (e.g. right after adding it).
  • Adds mock support for wbcheckconstraints in the offline test harness (test/conftest.py) and unit tests in test/test_wbi_helpers.py.

Closes #154

Test plan

  • python -m pytest test/ --ignore=test/integration (191 passed)
  • New TestCheckConstraints unit tests cover: missing id error, single/multiple entity ids, claim id, status filter

LeMyst and others added 2 commits July 4, 2026 10:11
Uses the target instance's own wbcheckconstraints API action (from the
WikibaseQualityConstraints extension) instead of a hardcoded, Wikidata-specific
rule set, so it works against any Wikibase instance with the extension installed.

Closes #154

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@LeMyst LeMyst merged commit 348c1ae into master Jul 4, 2026
15 checks passed
@LeMyst LeMyst deleted the issue-154 branch July 4, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check constraints before adding statement

1 participant