New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accommodate Sphinx option by changing docstring return type of "integer" to "int". #100989
Comments
|
You can change "integer" to "int" if you like. The other changes look gratuitous. Also, PEP 7 predates modern type annotations. Doc strings are allowed to put any text as the return type as long as it is interpretable by a human. It is unfortunate that Sphinx is assuming otherwise. How would it handle user defined types or types defined in type comments? |
collections.deque not compliant to PEP-7|
Ok, thanks for your feedback!
Still, changing it to cpython/Modules/atexitmodule.c Line 211 in 0ace820
cpython/Modules/_threadmodule.c Line 190 in 762745a
Line 28 in 81f7359
Although to be fair, I also found quite a few other modules which use an inconsistent format, e.g. Line 160 in 3e06b50
which I would change to time() -> float to match the correct type and allow the cross-referencing between documentations.
Are there better options to annotate types in C modules? If so, I think it should be mentioned in the docs of
User defined types are usually documented in the project that Sphinx is invoked in, and thus it'll find the reference to the custom type. |
Bug report
When
collections.dequeis subclassed and the resulting class is documented with Sphinx using the option:inherited-members:, the following error appears:I assume this is because the
PyDoc_STRVARdocstring of the C-implementation is not compliant to PEP-7 as required inPyDoc_STRVAR:cpython/Modules/_collectionsmodule.c
Lines 992 to 993 in d9dff4c
And everything after
->is interpreted as type hint.This can be reproduced with e.g. a python module
sub_deque.py:and a documenation file
docs/src/sub_deque.rst:which is then built with Sphinx:
sphinx-build -W docs/src docs/dist.I'd be happy to provide a patch for this myself if you feel this issue should be fixed.
Your environment
Linked PRs
collections.deque#100990The text was updated successfully, but these errors were encountered: