-
-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Labels
Description
With autodoc (.. automodule:: ...
),
if sys.version_info < (3, 8, 0):
from typing_extensions import Literal # this line
else:
from typing import Literal
causes "expected indented block" error.
To Reproduce
Steps to reproduce the behavior:
<Paste your command-line here which cause the problem>
$ git clone https://github.com/achimnol/aiotools
$ cd aiotools
$ pip install -r requirements/dev.txt
$ cd docs
$ make html
Expected behavior
It should build the docs.
Environment info
- OS: Linux (Ubuntu 20.04)
- Python version: 3.9.5
- Sphinx version: 4.0.1, 4.1.0dev installed from GitHub
- Sphinx extensions: sphinx.ext.autodoc, sphinx_autodoc_typehints
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
cblegare commentedon Sep 9, 2021
Got a similar error when I have class definitions nested in functions
cblegare commentedon Sep 13, 2021
Found the root cause in my case. To reproduce, document an
async
function wih a nested function definition.Example
the
normalize_source_lines
function does not detectasync def
as a function definition., thus provide invalid python as output:I'll try to submit a quick PR about this..
@achimnol that might fix it fr you too
cblegare commentedon Sep 13, 2021
#182
achimnol commentedon Dec 19, 2021
This is still happening with Sphinx 4.3 and sphinx-autodoc-typehints 1.12.0, on Python 3.10.
@cblegare's PR is about fixing the issue only for
async def
lines, but my issue is unrelated with them but just a version-conditional import. Changing my import statement to usetry: ... except ImportError: ...
gives me the same error.gaborbernat commentedon Jan 8, 2022
A PR for this would we welcome.