Setting up Pylint with PyDev

被刻印的时光 ゝ 提交于 2019-11-30 01:41:49
ariddell

I'm guessing you may need to mark the folder that contains your code as a source folder. You can do this under project properties.

  • Project->Properties->PyDev-PYTHONPATH
  • add relevant folders to the list of sources.

I've noticed that Pydev won't run Pylint on files with dashes (hyphens) the the filename; according to the Pydev devs, '-' is not a valid Python module name character, and it doesn't look like they intend to fix it:

http://sourceforge.net/tracker/index.php?func=detail&aid=1915426&group_id=85796&atid=577329

http://sourceforge.net/tracker/index.php?func=detail&aid=2888890&group_id=85796&atid=577332

As if nobody writes scripts in Python... Grumble grumble...

Acumenus

To provide an alternative solution, pylint can be used as an External Tool in Eclipse. This requires having previously installed the pylint package for a Python installation.

Remember to first have a pylintrc file somewhere where pylint can find it, failing which a "No config file found" error is printed. Typically I would touch pylintrc inside the project directory, and keep the file in version control. For reference, see pylint command-line options.

In Eclipse, select Run, External Tools, External Tools Configurations.... Click the toolbar button to create a New launch configuration. Configure as below or as desired:

  • Name: pylint
  • Location: ${system_path:pylint}
  • Working Directory: ${project_loc}
  • Arguments: --reports=n "${resource_loc}"

Remember to click inside an open file to switch focus to it before running the above external tool for it. Failing this, an error can occur.

The output of the external tool will by default be printed to the console.


Related: Setting up pep8 as an External Tool in Eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!