Typing spec should be clearer that type checkers are not expected to support PEP 3141
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 38/100
- Tipo de issue
- Documentação
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- python
- Domínio
- documentation
Direção de pesquisa
Comece pela página “Special cases for float and complex” da typing spec e compare sua redação com as passagens vinculadas de PEP 484 e PEP 3141. Esclareça que as ABCs de PEP 3141 não são as anotações numéricas recomendadas e que os verificadores de tipo podem não oferecer suporte a elas; a passagem atualizada deve preservar a explicação existente sobre o atalho numérico.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
With regards to the numeric tower, PEP 484 states:
PEP 3141 defines Python’s numeric tower, and the stdlib module
numbersimplements the corresponding ABCs (Number,Complex,Real,RationalandIntegral). There are some issues with these ABCs, but the built-in concrete numeric classescomplex,floatandintare ubiquitous (especially the latter two :-).Rather than requiring that users write
import numbersand then usenumbers.Floatetc., this PEP proposes a straightforward shortcut that is almost as effective: when an argument is annotated as having typefloat, an argument of typeintis acceptable; similar, for an argument annotated as having typecomplex, arguments of typefloatorintare acceptable. This does not handle classes implementing the corresponding ABCs or thefractions.Fractionclass, but we believe those use cases are exceedingly rare.
This is a very useful passage to link to, because:
- It clearly (albeit tersely) states that the PEP-3141 ABCs are problematic
- It clearly states the separate solution that PEP-484 proposes for dealing with numeric types
- It frames the PEP-484 solution in opposition and contrast to the PEP-3141 solution
The parallel passage in the typing spec currently states this:
Python’s numeric types
complex,floatandintare not subtypes of each other, but to support common use cases, the type system contains a straightforward shortcut: when an argument is annotated as having typefloat, an argument of typeintis acceptable; similar, for an argument annotated as having typecomplex, arguments of typefloatorintare acceptable.
Since PEP-484 is a historical document rather than a piece of living documentation, it would be great if the typing spec could state as clearly as PEP-484 that the PEP-3141 ABCs are not the recommended way of annotating numeric types in Python, and that type checkers may not necessarily (and in fact probably won't ever) support them.
- Linguagem predominante
- Python
- Estrelas
- 1.8k
- Forks
- 302
- Merge médio
- 23h
- PRs com merge (30d)
- 8
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python/typing
-
topic: typing spec
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
topic: typing spec
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
-
topic: documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
topic: documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
-
topic: conformance tests topic: typing spec
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 72/100
Todas as issues de python/typing
Issues semelhantes
-
link-check link-check:sphinx-theme
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
OpenHands/extensions#626 · 1 comentário ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
CSCfi/sd-search-api#39 ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100