python / python/cpython

Clarifying documentation of typing.Set

Aperta
#93,579 4 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

3.10 3.11 3.12 docs topic-typing
Lingua principale
Python
Stelle
77.2k
Fork
36k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Documentation

Edit: I added some more clarification.

Documentation of typing.Set is not entirely clear

The typing module's documentation currently requires two hops when the reader looks up typing.Set.

  1. In the docstring of typing.Set it states "To annotate arguments it is preferred to use an abstract collection type such as AbstractSet." This is referring to typing.AbstractSet
  2. Docstring of typing.AbstractSet says that it is deprecated and refers the reader to collections.abc.Set, which has no docstring of its own (it is grouped together with the docstring of collections.abc.MutableSet.
    I feel we can prevent these two hops i.e. typing.Set --> typing.AbstractSet --> collections.abc.Set and direct the reader to the final destination i.e. typing.Set -> collections.abc.Set.

Suggested change

  1. typing.Set should say something like --

"To annotate arguments it is preferred to use an abstract collection type such as collections.abc.Set.
"To annotate everything else, the use of typing.Set is deprecated since version 3.9: builtins.set now supports []. See PEP 585 and Generic Alias Type"

  1. Docstring of typing.AbstractSet is fine as it is.
  2. collections.abc.Set should say something like --

"Use this to annotate arguments. For all other annotations, use builtins.set, which now supported []. See PEP 585 ...

Other generic alias types like List, Tuple, FrozenSet etc. probably could use a similar change (IF others agree that this is something that needs to changed at all.)

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.

Direzione di ricerca

Inizia con le docstring per typing.Set e collections.abc.Set, quindi confronta la documentazione correlata sugli alias generici e le indicazioni contenute in PEP 585. Il lavoro è completato quando la documentazione indirizza i lettori da typing.Set a collections.abc.Set senza il passaggio intermedio aggiuntivo e spiega chiaramente quando usare builtins.set.

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

Valutazione

Stack tecnologico
python
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.