You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Pylint的msg-template中配置可点击的文件URL路径?

Fixing Clickable File Paths for Pylint in Windows PyCharm Terminal

I’ve run into this exact issue before—Windows’ backslash paths don’t play nice with the file:/// URI scheme that PyCharm recognizes for clickable links. The fix is straightforward: we just need to convert those backslashes to forward slashes directly in Pylint’s message template, using Python’s string replacement capabilities that the template system supports.

Here’s how to set it up:

Option 1: Command Line (One-Time Use)

When running Pylint in PyCharm’s terminal (either CMD or PowerShell), use this modified --msg-template parameter:

pylint --msg-template='(file:///{abspath.replace("\\\\", "/")}:{line}) :{column}: {msg_id}: {msg} ({symbol})' your_target_file_or_dir.py

The \\\\ is necessary because command shells treat backslashes as escape characters—we need two to represent a single literal backslash, and another two for the Python format string’s own escape. This replaces every backslash in the file path with a forward slash, turning a path like C:\Projects\app.py into C:/Projects/app.py—which works perfectly with the file:/// scheme.

Option 2: Pylint Configuration File (Permanent Fix)

For a long-term solution, add this line to your pylintrc file (create one if you don’t have it with pylint --generate-rcfile):

msg-template=(file:///{abspath.replace("\\", "/")}:{line}) :{column}: {msg_id}: {msg} ({symbol})

Here we only use two backslashes because we’re not dealing with command shell escaping—this directly tells Python to replace each backslash in the absolute path with a forward slash.

How It Works

Once configured, Pylint will output links like file:///C:/Projects/app.py:42—PyCharm’s terminal automatically recognizes this as a valid local file URI, and clicking it will jump straight to line 42 of app.py. Even paths with spaces will work correctly, no extra encoding needed.

内容的提问来源于stack exchange,提问作者Stefan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 14:57:31