[spec] Clarification: Are symbols not listed in `__all__` ever considered public?
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 302
- Merge medio
- 23h
- PR unite (30g)
- 8
Descrizione
According to https://typing.readthedocs.io/en/latest/guides/libraries.html#library-interface-public-and-private-symbols:
A module can expose an
__all__symbol at the module level that provides a list of names that are considered part of the interface. This overrides all other rules above, allowing imported symbols or symbols whose names begin with an underscore to be included in the interface.
Does this mean that if __all__ is present: ① A symbol is public if and only if it is listed in __all__ or ② If a symbol is listed in __all__, it is public, but things not listed in __all__ can still be considered public as well?
For example:
# module.py
__all__ = ["identity"]
from typing import TypeVar
T = TypeVar("T")
def identity(x: T) -> T:
return x
Are TypeVar and T considered public members of module.py? If so, what is the suggested way to exclude them? T could be renamed to _T, but is one supposed to do from typing import TypeVar as _TypeVar, if one wants TypeVar to not be considered a public member of module?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la guida collegata «Library Interface: Public and Private Symbols» e confronta la formulazione di all con l’esempio module.py nell’issue. Il lavoro è completo quando il comportamento dei simboli pubblici è chiarito nella documentazione, incluso il modo in cui i nomi importati e le dichiarazioni TypeVar devono essere esclusi quando appropriato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100