Add positional-only parameters
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
- backend-api-design
Research direction
Start with PEP 570 and the issue's Point example, then examine how attrs' attrib option and generated repr currently handle parameters. Define the expected positional-only behavior and verify that the example produces Point((0, 1, 2)) rather than Point(_data=(0, 1, 2)).
Written by the indexing model from the issue text.
Description
With PEP 570, positional-only parameters were introduced.
Similarly to keyword-only parameters, I would like to see these as an option for attrs.
One thing that makes them "special" is that the __repr__ method would behave differently for positional-only parameters than it would for regular positional parameters.
An example I would use in my libraries:
from attr import attrib, attrs
@attrs(auto_attribs=True)
class Point:
"""A three-dimensional point."""
_data: Tuple[float, float, float] = attrib(positional_only=True)
print(Point((0, 1, 2)))
The output would then be
Point((0, 1, 2))
instead of
Point(_data=(0, 1, 2))
If this were a desirable feature, would this be a good "first pull request" I could follow up on?
- 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
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100