python-attrs / python-attrs/attrs

Provide a builtin validator that takes a boolean function.

Open
#832 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature
Dominant language
Python
Stars
5.8k
Forks
480
Avg merge
2h 15m
Merged PRs (30d)
2

Description

Currently, validators are required to raise an exception, if the value isn't appropriate. If I currently have a function for checking the property, but returns a boolean, instead of raising, to use it as a validator, I have to write a wrapper that converts the return to an exception. It would be nice if attrs provided such a wrapper itself.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing validator entry points and reviewing how validators signal invalid values. Define the expected behavior for wrapping a boolean-returning function, including its invalid-value error, and confirm the validator API and documentation consistently describe the new option.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.