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
I have installed the module doing pip install -e ..
Problem
When running mypy from the command line, there are no issues with test_xxx.py. When running flycheck-mypy from emacs, I got tons of warnings similar to:
test_settings.py:7: error: Cannot find implementation or library stub for module named 'module.settings'
The problem occurs because flycheck run mypy from the tests folder and not the root one. Even if I specify a mypy config file, the error persists.
Potential fix
There is :working-directory option for flycheck checkers that could be used. Mine look like this (only works for setup.cfg currently):
(defunflycheck-mypy--find-project-root (_checker)
"Compute an appropriate working-directory for flycheck-ruby.This is either a parent directory containing a Gemfile, or nil."
(and
buffer-file-name
(locate-dominating-file buffer-file-name "setup.cfg")))
(flycheck-define-checker python-mypy
"Mypy syntax checker. Requires mypy>=0.3.1.Customize `flycheck-python-mypy-args` to add specific args to defaultexecutable.E.g. when processing Python2 files, add \"--py2\".See URL `http://mypy-lang.org/'.":command ("mypy"
(config-file "--config-file" flycheck-mypy.ini)
(eval flycheck-python-mypy-args)
source-original)
:working-directory flycheck-mypy--find-project-root
:error-patterns
((error line-start (file-name) ":" line ": error:" (message) line-end)
(warning line-start (file-name) ":" line ": note:" (message) line-end)
(info line-start (file-name) ":" line ": note:" (message) line-end))
:modes python-mode)
(add-to-list'flycheck-checkers'python-mypyt)
It should be possible to adapt this to either have a variable to define the directory, or use the directory of flycheck-mypy.ini.
The text was updated successfully, but these errors were encountered:
I have the following directory structure (standard for a python package I think):
I have installed the module doing
pip install -e .
.Problem
When running
mypy
from the command line, there are no issues withtest_xxx.py
. When runningflycheck-mypy
fromemacs
, I got tons of warnings similar to:The problem occurs because
flycheck
runmypy
from thetests
folder and not the root one. Even if I specify amypy
config file, the error persists.Potential fix
There is
:working-directory
option forflycheck
checkers that could be used. Mine look like this (only works forsetup.cfg
currently):It should be possible to adapt this to either have a variable to define the directory, or use the directory of
flycheck-mypy.ini
.The text was updated successfully, but these errors were encountered: