python / python/cpython

Clarifying documentation of typing.Set

Aberta
#93,579 4 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

3.10 3.11 3.12 docs topic-typing
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece pelas docstrings de typing.Set e collections.abc.Set e, em seguida, compare a documentação relacionada sobre aliases genéricos e as orientações da PEP 585. Considera-se concluído quando a documentação direcionar os leitores de typing.Set para collections.abc.Set sem a etapa intermediária extra e explicar claramente quando usar builtins.set.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
documentation
Tipo de issue
Documentação
Dificuldade
2/5
Tempo estimado
1-3 horas
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.