types.MappingProxyType states that proxy[key] will throw a KeyError, but that is not always true
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Documentation
In the documentation, it states proxy[key] will:
Return the item of the underlying mapping with key key. Raises a KeyError if key is not in the underlying mapping.
https://docs.python.org/3/library/types.html#types.MappingProxyType
However, it is possible to get an AttributeError instead, and in fact, unit tests for the dataclasses module require this to be true (metadata in dataclasses.field is wrapped in a mapping proxy):
The unit tests above are from Python3.12.
Looks like the CPython source code only forwards the getitem call to the inner mapping:
Guida per i contributori
Apri la guida per i contributori
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 dalla documentazione di MappingProxyType nella pagina collegata della documentazione Python, quindi confrontane la formulazione con i test dataclasses indicati e con l’implementazione in Objects/descrobject.c. Il lavoro è concluso quando la documentazione descrive accuratamente il comportamento delle eccezioni dimostrato dai test e dall’implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 58/100