[spec] clarification or change of "`partial\n` in a `py.typed` file"
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 1.8k
- Forks
- 302
- Merge moyen
- 23 h
- PR mergées (30 j)
- 8
Description
Reading through https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages today for unrelated purposes, it struck me that the occurrences of partial\n are ambiguous because it could be interpreted as requiring literally a backslash and an n. Furthermore, assuming \n is actually not to be taken literally (which is reasonable given that other places in the spec use glob stars anyway, although never in something you actually type into a file) it's ambiguous what happens if you use CRLF or CR as line terminators in your file. This also seems to rule out a file that just contains partial and then ends, without a newline character (you're not "supposed to" do this, but it happens).
To keep exactly the current behavior, I think this verbiage should be tweaked to "partial, followed by a newline". Perhaps the linefeed and carriage return characters could be mentioned explicitly, or a mention can be made of universal newlines.
However, I am not sure if the current behavior is actually important to specify, and I think other possibilities make more sense. Other possibilities include "partial on a line by itself", "partial surrounded by any amount of whitespace", and just "partial". "As the sole content of the file" may be added if desired.
A brief survey suggests that:
- mypy does
fscache.read(stub_typed_file).decode().strip() == "partial", which is not quite the same as the specified check - pyright does
(pyTypedContents.match(/partial\n/) || pyTypedContents.match(/partial\r\n/)), which is certainly a reasonable interpretation of the current spec, especially if you assume that no one ever uses only-CR newlines - ty does
to_ascii_lowercase().contains("partial")to be deliberately permissive, as explained in a comment
There is a reasonably long discussion about this topic over at https://discuss.python.org/t/pep-561-clarification-regarding-n/32875, but I didn't find it very enlightening.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par lire la section sur les paquets de stubs partiels dans distributing.html, puis comparez les vérifications liées de mypy, pyright et ty ainsi que le fil de discussion référencé sur discuss.python.org. Le travail est terminé lorsque la règle de correspondance prévue est définie et que la spécification est mise à jour pour l’énoncer sans ambiguïté, y compris le comportement concernant les sauts de ligne et la fin du fichier.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- documentation
- Type d'issue
- Documentation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100