Minimal problem case, if the content of routers.jinja2 is:
from anymodule import {{tag}}
generation will fail with a "list index out of bounds error".
Instead, this:
from anymodule import anything, {{tag}}
will work as expected.
From the trace of the failure, the problem seems to be that imports are checked in order to correctly insert commas, and in the first case a list ends up being empty probably due to the only import being a template variable.
In the following invoked isort code (from the trace), the "just_imports") list ends up being empty, while import string is from anymodule import
ending abruptly.
site-packages\isort\parse.py:522
if "," in import_string.split(just_imports[-1])[-1]:
trailing_commas.add(import_from)
I'm not sure if this is fixable since it depends on some other libraries' behaviour, but since adding any other name before {{tag}} makes it work, I thought it might have been worth the effort.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too