-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
[BUG] [Formatter] Shadowing built-in function breaks template #828
Comments
I’ve also encountered an similar issue when trying to format a set function. When trying to format
This behaviour suggests that the code after the equal sign is being executed as Python code, which I belive is unintended behaviour for a linter. Upon reviewing the code quickly, I suspect that the bug comes from the usage of the eval function here indent.py. However, I’m not sure about purpose of the eval function here. Maybe someone brighter than me can understand the |
Hi @FLiliequist , thanks for those details. This seems to be the commit that introduced for the purpose of formatting nodes that look like JSON5 or lists - it seems later commits might of increased the scope of where this code is executed so that now examples like yours & mine are now evaluated as well; seemingly for formatting functions / function parameters, etc.? I'm not sure if its supposed to, but it seems like |
Nice finding :) I have found a quick workaround for it, if I use the |
Ohhh I completely missed that. Thank you! |
Is there a plan to fix this one? If JS or Twig templates are used, checking for Python functions doesn't make that much sense imo 😊 |
I have the same issue working with template that rely on the
becomes
which breaks the layout. i managed to get away by installing version 1.24.0 |
System Info
Issue
If the template shadows a built-in function, such as
dir
, it gets replaced in the template with invalid code that breaks the template.How To Reproduce
Create a template file:
Running
djlint --reformat
produces:As in, the template's contents is now literally:
Which will crash when evaluated.
The text was updated successfully, but these errors were encountered: