sphinx-autodoc-typehints | Type hints support for the Sphinx autodoc extension | Theme library
kandi X-RAY | sphinx-autodoc-typehints Summary
kandi X-RAY | sphinx-autodoc-typehints Summary
Type hints support for the Sphinx autodoc extension
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Format an annotation .
- Backfill type hints .
- Inject a docstring into the docstring .
- Normalize source lines .
- Process sphinx signature .
- Determine the class name of the annotation .
- Return the arguments for the given annotation .
- Split a type comment .
- Process docstring .
- Resolve type guard imports .
sphinx-autodoc-typehints Key Features
sphinx-autodoc-typehints Examples and Code Snippets
Community Discussions
Trending Discussions on sphinx-autodoc-typehints
QUESTION
I get the following exception when running sphinx to generate the documentation for my project.
I am running on the ubuntu_latest architecture x64 on Github Actions. When running make html
on my own machine (latest version of Mac) I do not encounter any problems...
I am really lost here, so I would appreciate any help
...ANSWER
Answered 2021-Nov-05 at 08:50This issue apparently is known and has also been posted in spatialaudio/nbsphinx#596. As it says, a temporary fix is to downgrade the version of promt-toolkit
which must be lower than 3.0.0
.
You can explicitly downgrade with
pip install -U "prompt-toolkit<3.0.0"
Or simply add a rule in your requirements.txt
: prompt-toolkit<3.0.0
. Hopefully this incompatibility issue will be addressed soon.
QUESTION
I had just installed Anaconda from anaconda.com. The installation proceeded smoothly. After that, I was trying to create a new environment from this environment.yml file. (nbdev.yml)
...ANSWER
Answered 2021-Aug-04 at 05:11After a lot of research, I stumbled on to Mamba doesn't find a solution when mixing conda forge defaults and not specifying Python explicitly 1102. So I just edited nbdev.yml from
QUESTION
I'm currently trying out ParlAi by following the quickstart from the documentation. I already installed ParlAi and currently on "View a task & train a model" but when I run the code parlai display_data --task babi:task10k:1
, I got these tracebacks instead.
ANSWER
Answered 2021-Feb-13 at 10:40Yes, these tracebacks indicate errors. The kinds of errors here are pkg_resources.ContextualVersionConflict
which is kind of confusing because they don't have Error in their name. For these traceback blocks the last line is the error, the second to last is the way the error was raised.
pkg_resources.ContextualVersionConflict: (urllib3 1.25.8 (c:\users\dean\anaconda3\lib\site-packages), Requirement.parse('urllib3~=1.25.9'), {'parlai'})
Shows that you urllib3 is at 1.25.8, but it needs to be between 1.25.9 and 1.26.
pkg_resources.ContextualVersionConflict: (Sphinx 2.4.0 (c:\users\dean\anaconda3\lib\site-packages), Requirement.parse('Sphinx>=3.0'), {'sphinx-autodoc-typehints'})
means that your sphinx is 2.4.0 but should be greater than or equal to 3.0.
QUESTION
I am trying to auto document types with sphinx autodoc, napoleon and autodoc_typehints but I am having problems as it does not work with most of my types. I am using the deap
package to do some genetic optimization algorithm, which makes that I have some very specific types I guess sphinx cannot handle.
My conf.py
file looks like this:
ANSWER
Answered 2020-Apr-24 at 09:50After some searching there were some flaws with my approach:
- Firstly a "list is a homogeneous structure containing values of one type. As such,
List
only takes a single type, and every element of that list has to have that type." (source). Consequently, I cannot do something likeList[creator.Individual, creator.Individual]
, but should transform it toList[creator.Individual]
or if you have multiple types in the list, you should use an union operator, such asList[Union[int,float]]
- Secondly, the type
creator.Individual
is not recognized by sphinx as a valid type. Instead I should define it usingTypeVar
as such:
QUESTION
From the documentation, it says that:
Generic type
IO[AnyStr]
and its subclassesTextIO(IO[str])
andBinaryIO(IO[bytes])
represent the types of I/O streams such as returned byopen()
.— Python Docs:
typing.IO
The docs did not specify when BinaryIO
/TextIO
shall be used over their counterparts IO[str]
and IO[bytes]
.
Through a simple inspection of the Python Typeshed source, only 30 hits found when searching for BinaryIO
, and 109 hits for IO[bytes]
.
I was trying to switch to BinaryIO
from IO[bytes]
for better compatibility with sphinx-autodoc-typehints, but the switch-over has broken many type checks as methods like tempfile.NamedTemporaryFile
is typed as IO[bytes]
instead of the other.
Design-wise speaking, what are the correct situations to use each type of these IO type hints?
...ANSWER
Answered 2020-Jan-13 at 08:29BinaryIO
and TextIO
directly subclass IO[bytes]
and IO[str]
respectively, and add on a few extra methods -- see the definitions in typeshed for the specifics.
So if you need these extra methods, use BinaryIO/TextIO
. Otherwise, it's probably best to use IO[...]
for maximum flexibility. For example, if you annotate a method as accepting an IO[str]
, it's a bit easier for the end-user to provide an instance of that object.
Though all this being said, the IO classes in general are kind of messy at present: they define a lot of methods that not all functions will actually need. So, the typeshed maintainers are actually considering breaking up the IO class into smaller Protocols. You could perhaps do the same, if you're so inclined. This approach is mostly useful if you want to define your own IO-like classes but don't want the burden of implementing the full typing.IO[...]
API -- or if you're using some class that's almost IO-like, but not quite.
All this being said, all three approaches -- using BinaryIO/TextIO
, IO[...]
, or defining more compact custom Protocols -- are perfectly valid. If the sphinx extension doesn't seem to be able to handle one particular approach for some reason, that's probably a bug on their end.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sphinx-autodoc-typehints
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page