msherry / flycheck-pycheckers

Multiple syntax checker for Python in Emacs, using Flycheck
GNU General Public License v3.0
63 stars 23 forks source link

Adding support for pipenv #24

Closed bdc34 closed 1 year ago

bdc34 commented 5 years ago

This adds support for pipenv. Check if pipenv in affect for source_file's directory and uses that to set the checker executable and working directory.

bdc34 commented 5 years ago

There are some problems with this. One is that this is changing to the directory of the project when running the checker and that messes up the error messages so flycheck cannot jump to them in flycheck-list-errors. I'd not change dir, but then mypy cannot find the modules of the project. Setting PYTHONPATH didn't seem to affect 'pipenv run mypy'

So I'm not sure what to do to fix this.

msherry commented 5 years ago

Thanks for submitting this PR!

It sounds like it's not quite ready to be merged, and I am currently traveling, but I'll try to take a look at this in the next couple of days and see if I can help with it. I'll be upfront and let you know that I'm not very familiar with pipenv at all, but I'll play with it a bit and see if we can get this into shape. Thanks again!

msherry commented 5 years ago

Like I mentioned, I don't use pipenv much myself, but the changes look mostly reasonable. I've played around with setting the cwd arg to Popen before, but like you discovered, it leads to some issues when parsing the error messages.

Was it only mypy that is unable to run under pipenv? Any thoughts on why that might be the case?

bdc34 commented 5 years ago

I tried a couple things but I was unable to get mypy to correctly run in the directory of the checked source file. I assumed that running in that directory was a requirement otherwise the error messages directories didn't work when trying to link to the error in the source file.

To get flycheck to return useful errors I needed to run mypy in the directory of the checked source. But to get mypy to find the modules in the project I needed to run it at the root directory of the project.

When I added the project directory to PYTHONPATH that didn't help. I later found MYPATH and the mypy_path configuration. None of those helped this problem. They all left my packages undiscovered and produced errors like: factory.py:13: error: Cannot find module named 'browse.routes'

There are flags to turn off these error but they are critical to using typing within the project.

Mypy was the only runner that had this sort of problem.

I'm not sure what direction to go next with this.

bdc34 commented 1 year ago

Closed due to lack of interest.