Support for a validator argument to enable runtime validation
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- developer-experience
Research direction
Start by reviewing the attr.s and attr.ib APIs and the linked attrs-strict library to understand the proposed validator flow. Done means a class-level option can apply the requested validator to all existing attributes without repeating validator= on each field, with the behavior agreed and verified in the project’s tests.
Written by the indexing model from the issue text.
Description
A while ago I created https://github.com/bloomberg/attrs-strict a library to help with runtime validation of attrs classes.
The way it currently works is you need to "enable" it per attribute in the following manner:
attr.ib(validator=type_validator(), type=List[Tuple[str, str]])
But if you have multiple fields, and you want to apply the validation on all of them, it becomes repetitive. Additionally, you might miss adding it for some attributes.
Would you consider an argument that could enable it for all the existing attributes in an attrs class ?
Something along the lines:
attr.s(validate_with=type_validator())
class Something:
...
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-attrs/attrs
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
python-attrs/attrs#1620 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
python-attrs/attrs#1596 · 2 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
python-attrs/attrs#1549 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
python-attrs/attrs#1543 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
python-attrs/attrs#1532 ·
All issues in python-attrs/attrs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100