leinardi / pylint-pycharm

A plugin providing both real-time and on-demand scanning of Python files with PyLint from within PyCharm/IDEA.
Apache License 2.0
197 stars 35 forks source link

Add option to Lint "Sources" directories rather than excluded "Excluded" ones #13

Open switchtrue opened 5 years ago

switchtrue commented 5 years ago

Is your feature request related to a problem? Please describe. This plugin currently lints all directories that are not marked as "Excluded". This doesn't seem like a recommended behaviour, most notably, the use of a virtualenv is very popular in the python community and the virtualenv directory will often sit inside your project in a folder called venv or similar. Marking your virtualenv directory as "Excluded" would not be normal practice when using pycharm. Similarly its common to have various useful scripts in directories that are not part of the module and are undesirable to have linted. Auto-generated migrations sometimes to not want to be linted either.

Describe the solution you'd like Ideally rather than linting all files except those marked as "Excluded" it would instead only lint those directories marked as a "Sources Root".

Describe alternatives you've considered Marking all directories except one as "Excluded".

Additional context This change would essentially be a backwards incompatible change without updating configuration. Perhaps there could be a setting for this to avoid the issue?

leinardi commented 5 years ago

I have discussed about this topic already with a PyCharm developer:

image

Marking your virtualenv directory as "Excluded" would not be normal practice when using pycharm.

Are you sure about this? Because my experience is that if I add a venv directly from PyCharm settings, it is excluded automatically.

Anyway I cannot enable such feature by default because, as explained by the PyCharm dev, in PyCharm there is no enforcement of a rigid project structure like in IntelliJ IDEA.

But I agree that this could be an optional setting.

I am not sure when I will be able to work on this feature, I have to first fix the most urgent issues but feel free to make a PR if you want. It should be quite easy to implement: just adding a checkbox inside the settings, persisting the value and checking projectFileIndex.isInSource(file) if the setting is enabled here (very similar to what you did in #9):

https://github.com/leinardi/pylint-pycharm/blob/76e754ca31dc39928c8dc04498a833dfee66e7bd/src/main/java/com/leinardi/pycharm/pylint/util/VfUtil.java#L72

switchtrue commented 5 years ago

You are totally right. For whatever reason I've always created my virtualenvs and the command line and then just open the directory in Pycharm, but yes, creating one via New Project does mark it as excluded. As such, I'm happy that this plugin follows convention and will adopt this pattern.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had activity in the last 60 days.