简体   繁体   中英

How to suppress a certain warning in Spyder editor?

The editor in Spyder always gives me warnings for unused imports/variables immediately after I type the line. I want to suppress such warnings. How do I do that? And I want this to happen for every file I open in the Spyder editor, wouldn't prefer local fixes.

I tried adding 'disable=' in ~/.pylintrc and it didn't work. Moreover, the Spyder editor uses pyflakes anyway.

You need to go to

Tools > Preferences > Editor > Code Introspection/Analysis

and deactivate the option called

Real-time code analysis

import warnings

warnings.filterwarnings("ignore")

In Spyder the linter pyflakes is used. You can write a special comment at the end of the line to ignore the line. The following comments work:

from mpl_toolkits.mplot3d import Axes3D  # noqa
from mpl_toolkits.mplot3d import Axes3D  # analysis:ignore

找到首选项 -> 编辑器 -> 代码自省/分析 -> 停用/取消选中实时代码分析警告:它也将停止在编辑器中显示错误

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM