Alex Bennée <[email protected]> writes:

> 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.

Gentle ping for any fellow Emacers who also hack on the python code.

>
> Signed-off-by: Alex Bennée <[email protected]>
> ---
>  .dir-locals.el | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/.dir-locals.el b/.dir-locals.el
> index 3ac0cfc6f0d..51871619422 100644
> --- a/.dir-locals.el
> +++ b/.dir-locals.el
> @@ -1,2 +1,8 @@
>  ((c-mode . ((c-file-style . "stroustrup")
> -         (indent-tabs-mode . nil))))
> +         (indent-tabs-mode . nil)))
> + (python-mode .
> +              ((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))))))))

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

Reply via email to