Skip to content

feat: Allow users to set custom rule names#274

Open
AndreasAlbertQC wants to merge 5 commits intomainfrom
rule-names
Open

feat: Allow users to set custom rule names#274
AndreasAlbertQC wants to merge 5 commits intomainfrom
rule-names

Conversation

@AndreasAlbertQC
Copy link
Collaborator

Motivation

Addresses part of #122

Changes

  • Added name argument to dy.rule, which allows users to set a custom name that will show up in any failure outputs.

@github-actions github-actions bot added the enhancement New feature or request label Feb 16, 2026
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (573b564) to head (5a6ce9e).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #274   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           54        54           
  Lines         3125      3129    +4     
=========================================
+ Hits          3125      3129    +4     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a name parameter to the @dy.rule() decorator, allowing users to specify custom, user-friendly names for validation rules that will appear in failure reports. This addresses part of issue #122, which requested the ability to assign friendly names to rules for better failure reporting.

Changes:

  • Added optional name parameter to @dy.rule() decorator for custom rule naming
  • Implemented validation to prevent duplicate rule names and reserved name conflicts (e.g., "primary_key")
  • Added tests for custom rule names in both regular and group rules, plus error cases

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
dataframely/_rule.py Added name parameter to RuleFactory.__init__() and rule() decorator with updated docstring
dataframely/_base_schema.py Updated metadata extraction to use custom names, added validation for duplicate and reserved names
tests/schema/test_rule_implementation.py Added tests for illegal rule names (reserved "primary_key") and duplicate custom names
tests/schema/test_filter.py Added tests verifying custom rule names appear correctly in FailureInfo.counts() for both regular and group rules

@AndreasAlbertQC AndreasAlbertQC marked this pull request as ready for review February 17, 2026 08:29
Copy link
Member

@borchero borchero left a comment

Choose a reason for hiding this comment

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

I'm not sure you can answer that question because you didn't write the initial issue report... 😄 but what's the rationale of assigning custom names to rules but not being able to provide custom names to column-level checks 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants