Peter Maydell <[email protected]> writes:

> On Thu, 12 Nov 2026 at 17:19, Alex Bennée <[email protected]> wrote:
>>
>> Markus Armbruster <[email protected]> writes:
>>
>> > Peter Maydell <[email protected]> writes:
>> >
>> >> On Fri, 23 Oct 2026 at 19:06, Alex Bennée <[email protected]> wrote:
>> >>>
>> >>> When editing python code the linters tools have a hard time with our
>> >>> imports as they can't be found. To ease this we can expand a
>> >>> PYTHONPATH in .dir-locals so at least Emacs users can have less
>> >>> warnings in their editor.
>> >>>
>> >>> I still get complaints from python-mypy about missing library stubs
>> >>> that mean it can't do proper type analysis though.
>
>> >> With this change, emacs now complains and prompts for input every
>> >> time I open a Python file inside the QEMU source tree:
>> >>
>> >> ===begin===
>> >> The local variables list in /home/pm215/qemu/
>> >> or .dir-locals.el contains values that may not be safe (*).
>> >>
>> >> Do you want to apply it?  You can type
>> >> y  -- to apply the local variables list.
>> >> n  -- to ignore the local variables list.
>> >> !  -- to apply the local variables list, and permanently mark these
>> >>       values (*) as safe (in the future, they will be set
>> >> automatically.)
>>
>> It should mark them as safe for this particular directory, not generally
>> for setting PYTHONPATH.
>>
>> >> i  -- to ignore the local variables list, and permanently mark these
>> >>       values (*) as ignored
>> >>
>> >>   * eval : (when-let* ((root (locate-dominating-file default-directory
>> >> ".dir-locals.el"))) (setq-local process-environment (copy-sequence
>> >> process-environment)) (setenv "PYTHONPATH" (concat (expand-file-name
>> >> "python" root) ":" (expand-file-name "tests/functional" root))))
>> >> ===endit===
>> >>
>> >> The commit messages says "so Emacs users can have less warnings"
>> >> but from my POV this is "more warnings" (and previously I didn't
>> >> notice any warnings at all).
>> >
>> > Same here.
>> >
>> > What exactly was the problem this patch tried to solve?
>>
>> It ensures the python lsp's don't complain about invalid imports because
>> they don't have visibility of the PYTHONPATH set by ./run
>
> That's a bit unfortunate, but I think it's a lot less bad
> than emacs complaining every single time you open a python file.

If you trust a project not to do bad things you can set:

  safe-local-variable-directories

which for me is set to:

  ("/home/alex/lsrc/qemu.git/")

But I take your point. I'll figure out how to do this without
.dir-locals and send a revert documenting it.

>
> -- PMM

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

Reply via email to