Inline python declared with `exec s:inline_python` results in treating python as error
While the following vimscript is linted correctly:
python << EOF
import os
EOF
the following, even though equivalen, results in an error on third line:
let s:inline_python = 'python << EOF'
exec s:inline_python
import os
EOF
This way of declaring inline python can be useful when s:inline_python has different value depending on the python interpreter that should be used.
@bstaletic Thanks for the report.
I want to see the error occurred. Could you show me the error message, please?
@Kuniwak
File producing the error, named test.vim:
let s:inline_python = 'python << EOF'
exec s:inline_python
import os
EOF
Vint command used: vint -f '{file_path}:{line_number}:{column_number}:{severity}:{description} ({policy_name})' -s test.vim
Error reported by vin: test.vim:3:1:error:E492: Not an editor command: import os (SyntaxError)
Note: This need not be an import line that causes the error, but any line that is valid python, but invalid vimscript.
I confirmed the problem. But I think this cause is in vim-vimlparse.
vint._bundles.vimlparser.VimLParserException: vimlparser: E492: Not an editor command: import os: line 3 col 1
I reported this issue by https://github.com/ynkdir/vim-vimlparser/issues/33
Just for reference: test/fixture/ast/inline_python.vim has been added (probably accidentally) in 9816a31.
It would be nice if vint would allow to ignore whole sections of a file completely (i.e. exclude it from having it parsed/handled by vimlparser in the first place).