console.show()
console.clear()
console.run('cmd.exe /c '
+ 'C:\\Python26\\Scripts\\pylint.bat --reports=n -f parseable '
+ '"%s"' % notepad.getCurrentFilename())
在当前版本的Pylint中,选项"-f parseable"已被废弃。
当前的等效替代方案是:
console.run('cmd.exe /c '
+ 'C:\\Python26\\Scripts\\pylint.bat --reports=n '
+ '--msg-template="%s" %s'
% ( '{path}:{line}: {msg_id}({symbol}), {obj} {msg}', notepad.getCurrentFilename()))
注意:Python路径可能不同,例如C:\\Python27
。
注意2:在--msg-template="..."
中双引号很重要。
其他答案对我都无效,但这个有效:
Install PyLint using python -m pip install pylint
Install NppExec via the Plugin Manager, press F6, and save this script as "PyLint":
NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
env_set PYTHONIOENCODING=utf-8
python -u -m pylint "$(FULL_CURRENT_PATH)"
样例输出:
NPP_SAVE: C:\Users\Cees\Documents\http_ear.py
CD: C:\Users\Cees\Documents\http_ear.py
Current directory: C:\Users\Cees\Documents
ENV_SET: PYTHONIOENCODING=utf-8
$(SYS.PYTHONIOENCODING) = utf-8
python -u -m pylint "C:\Users\Cees\Documents\http_ear.py"
Process started (PID=25136) >>>
************* Module http_ear
http_ear.py:16:0: C0301: Line too long (1780/100) (line-too-long)
http_ear.py:17:0: C0301: Line too long (226/100) (line-too-long)
http_ear.py:26:0: C0304: Final newline missing (missing-final-newline)
------------------------------------------------------------------
Your code has been rated at 8.00/10 (previous run: 8.00/10, +0.00)
<<< Process finished (PID=25136). (Exit code 16)
================ READY ================
FF
:%FILE%:%LINE%:%CHAR%
python -m pip install pylint
安装 PyLint,并通过 Notepad++ 的 Run...
命令(F5)来使用它:cmd /c python -m pylint "$(FULL_CURRENT_PATH)" & pause
要在Notepad++中获取输出并链接到代码,使用NppExec。
cmd /c pylint "$(FULL_CURRENT_PATH)" & pause
。 - Pugsley如果您想在NotePad++中使用Pylint,应该使用可执行文件而不是批处理。
从Python脚本的配置中创建一个新的.py文件来运行Pylint。(我称之为npphelper.py)
(将npphelper.py添加到菜单项和工具栏图标中,然后您可以通过按按钮来执行它。)
这将在Notepad++中运行Pylint,我将命令分成了两个部分:
pyLint = 'C:\\PROGRA~1\\Python35\\Scripts\\pylint.exe --reports=n'
console.show()
console.clear()
console.run('%s "%s"' % (pyLint, notepad.getCurrentFilename()))
(您必须更改路径,以使其适合您的安装...)
现在您所要做的就是保存此npphelper.py,打开包含项目文件的选项卡并运行您为pylint创建的npphelper.py。(例如通过按钮)
如果您不想使用默认配置,则可以生成 pylintrc 模板(将它们保存在希望的位置)。我是通过以下命令在 CMD 中完成的:
pylint.exe --generate-rcfile>>myfilename.pylintrc
那么你需要在npphelper.py中更改一些行:
rcfile = 'C:\\PROGRA~1\\Python35\\Scripts\\myrcfile.pylintrc'
pyLint = 'C:\\PROGRA~1\\Python35\\Scripts\\pylint.exe --reports=n --rcfile="%s"' % rcfile
console.show()
console.clear()
console.run('%s "%s"' % (pyLint, notepad.getCurrentFilename()))
我已经使用.msi文件这里安装了Python脚本1.0.8.0及其所有附加组件。
(使用Notepad++中的PluginManager会得到1.0.6.0版本而不是1.0.8.0)
我使用Windows 7,Notepad++ 6.9.1,Python 3.5.1和Pylint 1.5.5。
(我通过CMD安装了pylint -> "pip install pylint"并进行了更新。)
更多有用的链接: