通过 pylint 处理用户提出的弃用警告

发布于 2024-09-19 21:19:25 字数 109 浏览 2 评论 0原文

有没有办法告诉 pylint 当它看到用户定义的弃用警告时必须显示警告消息?

我尝试过 warnings.warn、DeprecationWarning - 但 pylint 会忽略它们。

Is there a way to tell pylint that it must show warning message when it see user-defined deprecation warning?

I've tried warnings.warn, DeprecationWarning - but pylint ignores them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛夏已如深秋| 2024-09-26 21:19:25

由于 warnings.warn &c 旨在在运行时发生,Pylint 默认情况下不会将它们视为任何奇怪的事情。要改变这一点,我认为您需要遵循 编写您自己的检查器,使用它您可以针对源的任何特征(无论是原始源还是 AST 编译级别)发出警告。

Since warnings.warn &c are intended to happen at runtime, Pylint by default doesn't see them as anything strange. To change that I think you need to follow the (advanced and scarce) docs for writing your own checker, with which you can emit warnings on any characteristics of the sources (either the raw ones or the AST-compiled level thereof).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文