New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support linting inside current Virtualenv #7
Comments
Amazing plugin! I've worked around it locally by creating a pylint2 file which I point to and in it I add:
But in reality I would love to see that it adds all content roots which are marked as sources to pylint, or ability to select which source roots to use. |
That said, can't you simply install pylint in the virtualenv and point to this binary? This will still give you import errors for your own code, but for things installed in your venv it should work. Perhaps I'm missing something :) |
I actully tried this and uninstalling pylint from the host system and installing pylint in the virtualenv does work so I am using this plugin now, however it feels a bit... dirty? to include a linter in my project requirements. However I suppose I can simply change my thinking here and have a requirements.txt and a requirements-prod.txt and maintain both files. |
Hey guys, I am trying to find a solution but I am a Java developer that started to mess with Python only recently, so I need help to fully understand the problem. Currently I am able to get the path of the current environment used on the PyCharm project: The python tool you linked is sourcing the content of the venv path + "activate": https://github.com/tgamauf/pylint-pycharm/blob/ff16d80b894275623503bd0e6fe7a8a2903bb125/pylint_pycharm/converter.py#L132 Is this the only way? |
Ok, after some investigation it seems that the
I should be able to do those things directly from the plugin before running Pylint. I will provide a test build soon and I would love is someone of you guys could test it. |
I'm not sure if you need all that, or if you just can supply the binary to the virtualenv since that is the correct environment it (according to me) should run in. What would be nice would be if it can use your projects python interpreter (since that's often the virtualenv) |
OK, I think I fixed it. @Routhinator @bivald @kwiersma, @switchtrue please test this build an let me know if is fixed also for you: EDIT: |
This works perfectly! |
Fix #7: Support linting inside current Virtualenv
Hi all, unfortunately I just find out that the fix only works if you install Pylint in your virtualenv (@switchtrue can you please confirm this?). I just noticed that, after setting up a venv from scratch, the plugin was not recognizing Pylint executable, even after providing the full path:
Any idea on how to fix this? |
Ok, my current plan is to make the plugin install Pylint inside the virtualenv if is not already installed. But I have no idea how to do it. I have asked for help here. Perhaps @vlasovskikh will have a look at it :) |
Yes, I can confirm this! Interesting. I always install pylint inside my virtualenvs as I use different versions for different project. As long as the auto install only installs if it's not already found then I should still be able to install whatever version I want outside of the plugin and have the plugin use it. |
OK, I have a new fix for this issue. I implemented a better auto-detect for the Pylint executable and I can now install Pylint inside the current project interpreter if is missing. Please test this new version and let me know if works fine (if possible test multiple scenarios like a fresh project with no venv set, then one with a venv and another with the system env). |
Has anyone tested the new fix? Should I release it? |
Yes, apologies! I did and I started drafting a comment here but got distracted. It seems to work really well. The "Auto-detected: ..." message in the settings is a really nice touch. One issue I've noticed though it that it is linting files I have ignored in my pylintrc file. In pylintrc you can add an ignore like like this:
If I run pylint manually these do not get linted, but if I run via this plugin they do get linted and in my setup they fail which is a bit of an issue. All other pylintrc settings seem to get respected so I'm guessing this is an artifact of how the files are passed to pylint. Do you want me to raise another issue for this? |
Nice! Then I procede with a new release 👍
Mmm this could be hard to fix: the plugin is giving pylint a list of all the files it has to scan and I guess pylint is not respecting the pylintrc ignore if you ask to scan explicitly an ignored file... I will open a separate bug to keep track of this issue but I don't see any easy solution... |
Fix #7: Support linting inside current Virtualenv (v2)
Added action to configure project interpreter
Hello, I have a issue with using a hardcoded pylint path that's in a virtualenv. I'm using Intellij IDEA Ultimate 2018.2.4 on a Mac. The Pylint plugin is v0.10.2 I see:
in the log, even though the file is there and I can execute it directly. (I've also restarted the IDE many times.) Any ideas? |
Hi @cpchen, could you please attach the idea.log file (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files) after you get that error message? |
|
Mmm this looks strange, can you check if the Python interpreter is properly set in your PyCharm project? Can you try to switch to another one (e.g. local venv) to test if you get the same error? |
The Python interpreter is set to the one inside the venv the Pylint bin is in. I can try another venv, if you think that would make a difference? |
If you can post the entire idea.log here (you can use the attach feature), there is a problem with the path |
I am sorry but I fear this configuration is not currently supported. It looks like the python core plugin is giving back the wring path for the interpreter. |
Argh. So you think there's no configuration change I can make on my end? I
thought the Python plugin needs to respect what bin I pass it.
…On Fri, Oct 12, 2018, 10:08 AM Roberto Leinardi ***@***.***> wrote:
I am sorry but I fear this configuration is not currently supported. It
looks like the python core plugin is giving back the wring path for the
interpreter.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAho2yFuL2xeiEmzlmEzaHoXjMdzcz3zks5ukMyZgaJpZM4WYFnY>
.
|
I guess the plugin tries the wrong SDK. In IntelliJ there may be many SDKs for different programming languages. On the screenshot I see that the project has a Java 10 SDK and a Python 2.7 virutalenv SDK set up. @leinardi SDKs can be associated with a) the |
@cpchen I'm not sure that your issue is related to the original issue. It's clearly about running the plugin in IntelliJ with several SDKs set up. |
@vlasovskikh thank you for your comment, that information might be very useful in the future, but for now I have to find the interpreter without the need of a |
Looking at a comment in the top post in https://stackoverflow.com/questions/24769117/how-do-i-configure-a-python-interpreter-in-intellij-idea-with-the-pycharm-plugin it looks like I can create a Java project with Python facet for the same module. would you be able to grab the interpreter that way? |
let's move this discussion to #31 |
Is your feature request related to a problem? Please describe.
Linter does not have a setting to support virtualenvs. PyLint ends up reporting valid imports as errors.
Describe the solution you'd like
A setting to tell PyLint plugin to use the configured virtualenv, similar to https://github.com/perses76/pylint-pycharm.git so we can get proper reports from the linter.
Describe alternatives you've considered
I can workaround this by not using this plugin and simply configuring an external tool with https://github.com/perses76/pylint-pycharm.git for now (setup is here for any curious: https://stackoverflow.com/a/48549144/2262288)
The text was updated successfully, but these errors were encountered: