Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add positional-only parameters

Aperta
#641 3 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

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)).

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Feature

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?

Lingua principale
Python
Stelle
5.8k
Fork
480
Merge medio
2h 15m
PR unite (30g)
2

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-attrs/attrs

Tutte le issue di python-attrs/attrs

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.