Parse error when attempting to document a type alias `MapType = dict[str, float]`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- documentation
Direzione di ricerca
Usa il repository di riproduzione collegato, iniziando da src/repro_1956/type_aliases.py e dalla configurazione Sphinx a cui fa riferimento la relativa build make html. Installa requirements.txt ed esegui make html per riprodurre gli avvisi di autosummary relativi ai metodi integrati di dict. Il lavoro è completato quando l'alias documentato dict[str, float] non genera più questi avvisi e la build della documentazione termina correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When documenting with sphinx, sphinx.ext.autodoc and numpydoc the following type alias:
MapType = dict[str, float]
"""Alias for a dictionary of strings to floats"""
yields this error (truncated full below):
type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import clear.
Possible hints:
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.clear'; 'repro_1956.type_aliases' is not a package
* ModuleNotFoundError: No module named 'clear'
* KeyError: 'clear'
* ValueError: not enough values to unpack (expected 2, got 1)
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'clear'
However changing the alias to typing.Dict[str, float] avoids the error, as does disabling the numpydoc extension for sphinx. The problem appears to be that when the alias is dict[str, float] it attempts to document the dict class, as the partial documentation generated documents the dict.copy method.
Issue was originally observed with the following versions:
- Python 3.10
- numpydoc 1.5.0
- sphinx 4.5.0
And reproduced with versions:
- Python 3.10
- numpydoc 1.8.0
- sphinx==8.1.0
Full repro at https://github.com/dagardner-nv/repro_1956
Repro:
- Clone https://github.com/dagardner-nv/repro_1956
- Run the following commands:
cd repro_1956
pip install -r requirements.txt
make html
Full output:
$ make html
Running Sphinx v8.1.0
loading translations [en]... done
making output directory... done
[autosummary] generating autosummary for: index.rst
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import clear.
Possible hints:
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.clear'; 'repro_1956.type_aliases' is not a package
* ModuleNotFoundError: No module named 'clear'
* KeyError: 'clear'
* ValueError: not enough values to unpack (expected 2, got 1)
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'clear'
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import fromkeys.
Possible hints:
* KeyError: 'fromkeys'
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'fromkeys'
* ModuleNotFoundError: No module named 'fromkeys'
* ValueError: not enough values to unpack (expected 2, got 1)
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.fromkeys'; 'repro_1956.type_aliases' is not a package
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import get.
Possible hints:
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.get'; 'repro_1956.type_aliases' is not a package
* ValueError: not enough values to unpack (expected 2, got 1)
* ModuleNotFoundError: No module named 'get'
* KeyError: 'get'
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'get'
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import items.
Possible hints:
* KeyError: 'items'
* ModuleNotFoundError: No module named 'items'
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.items'; 'repro_1956.type_aliases' is not a package
* ValueError: not enough values to unpack (expected 2, got 1)
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'items'
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import keys.
Possible hints:
* ModuleNotFoundError: No module named 'keys'
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'keys'
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.keys'; 'repro_1956.type_aliases' is not a package
* KeyError: 'keys'
* ValueError: not enough values to unpack (expected 2, got 1)
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import pop.
Possible hints:
* ModuleNotFoundError: No module named 'pop'
* KeyError: 'pop'
* ValueError: not enough values to unpack (expected 2, got 1)
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'pop'
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.pop'; 'repro_1956.type_aliases' is not a package
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import popitem.
Possible hints:
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'popitem'
* ModuleNotFoundError: No module named 'popitem'
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.popitem'; 'repro_1956.type_aliases' is not a package
* ValueError: not enough values to unpack (expected 2, got 1)
* KeyError: 'popitem'
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import setdefault.
Possible hints:
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'setdefault'
* ValueError: not enough values to unpack (expected 2, got 1)
* ModuleNotFoundError: No module named 'setdefault'
* KeyError: 'setdefault'
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.setdefault'; 'repro_1956.type_aliases' is not a package
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import update.
Possible hints:
* KeyError: 'update'
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.update'; 'repro_1956.type_aliases' is not a package
* ModuleNotFoundError: No module named 'update'
* ValueError: not enough values to unpack (expected 2, got 1)
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'update'
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: failed to import values.
Possible hints:
* ModuleNotFoundError: No module named 'repro_1956.type_aliases.values'; 'repro_1956.type_aliases' is not a package
* ValueError: not enough values to unpack (expected 2, got 1)
* AttributeError: module 'repro_1956.type_aliases' has no attribute 'values'
* ModuleNotFoundError: No module named 'values'
* KeyError: 'values'
/home/dagardner/work/repro_1956/src/repro_1956/type_aliases.py:docstring of builtins.dict:9: WARNING: autosummary: stub file not found 'copy'. Check your autosummary_generate setting.
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets...
copying static files...
Writing evaluated template result to /home/dagardner/work/repro_1956/build/html/_static/basic.css
Writing evaluated template result to /home/dagardner/work/repro_1956/build/html/_static/language_data.js
Writing evaluated template result to /home/dagardner/work/repro_1956/build/html/_static/documentation_options.js
Writing evaluated template result to /home/dagardner/work/repro_1956/build/html/_static/js/versions.js
copying static files: done
copying extra files...
copying extra files: done
copying assets: done
writing output... [100%] index
generating indices... genindex py-modindex done
writing additional pages... search done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 11 warnings.
The HTML pages are in build/html.
- Lingua principale
- Python
- Stelle
- 354
- Fork
- 185
- Merge medio
- 4m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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.
Altre issue di numpy/numpydoc
-
Don't require ``RT01`` for propertiesForse di nuovo libera @Nani-2007-code l’ha presa 30 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
-
DOC: Version link overflowing on navbarForse di nuovo libera @swoyer2 l’ha presa 52 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
-
needs-decision
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Tutte le issue di numpy/numpydoc
Issue simili
-
00 - Bug component: numpy.linalg
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
521xueweihan/HelloGitHub#4543 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
emeryberger/CSrankings#15700 ·
I maintainer di solito rispondono entro 2 giorni
-
Bug | 工作不正常 Triage | 待检查
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
OneDragon-Anything/ZenlessZoneZero-OneDragon#3084 ·
I maintainer di solito rispondono entro 1 giorno
-
Task select patterns with uppercase letters never matchForse già presa @manobhisriram l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno