Typing problem for validator collections
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- developer-experience
Research direction
Start by locating the deep_iterable validator and its type annotations, then compare how list and tuple values are typed for member_validator. The change is complete when mypy accepts the shown example with a list of validators, while the existing tuple behavior remains valid.
Written by the indexing model from the issue text.
Description
This is a copy of the second issue collected in https://github.com/python-attrs/attrs/issues/1206 to enable separate tracking of the bug.
The issue
Consider the following piece of code:
@define
class A:
x: List[str] = field(
validator=deep_iterable(
member_validator=[instance_of(str), min_len(1)],
iterable_validator=and_(instance_of(list), min_len(1)),
),
)
When a list of validators is passed for member_validator, mypy complains about the type, as already pointed out in https://github.com/python-attrs/attrs/issues/1197. However, when a tuple is used instead, mypy is happy.
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 490
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 2/5 1-3 hours Newbie friendliness 78/100
python-attrs/attrs#1627 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-attrs/attrs#1637 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
python-attrs/attrs#1620 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
python-attrs/attrs#1596 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
python-attrs/attrs#1549 · 3 comments ·
Maintainers usually reply within 1 day
All issues in python-attrs/attrs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mikf/gallery-dl#9791 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
fossasia/eventyay#6151 · 1 comment ·
Maintainers usually reply within 1 day
-
P4: low tooling
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
jeffknupp/association#318 ·
-
azure-cost bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/GitHub-Copilot-for-Azure#3330 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
raullenchai/Rapid-MLX#4097 ·
Maintainers usually reply within 1 day