You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
MarcoCap
changed the title
Cannot use template variable {{tag}} in routers.jinja2 imports
Cannot use template variable {{tag}} in routers.jinja2 imports with modular templates
Jan 19, 2024
Minimal problem case, if the content of routers.jinja2 is:
generation will fail with a "list index out of bounds error".
Instead, this:
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.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.
The text was updated successfully, but these errors were encountered: