admin管理员组文章数量:1391982
I have recently switched from using mypy
to pyright
for static type checking. mypy
has a useful feature whereby it can be configured to warn you if it detects comments instructing it to ignore certain errors which would not actually be raised (described here: ).
Does anyone know if pyright
has a similar feature? I can't see any reference to it in their documentation. Ideally, it would apply to the pyright
specific ignore comments (# pyright: ignore [errorCode]
) as well as the generic # type: ignore
.
I have recently switched from using mypy
to pyright
for static type checking. mypy
has a useful feature whereby it can be configured to warn you if it detects comments instructing it to ignore certain errors which would not actually be raised (described here: https://stackoverflow/a/65581907/7256443).
Does anyone know if pyright
has a similar feature? I can't see any reference to it in their documentation. Ideally, it would apply to the pyright
specific ignore comments (# pyright: ignore [errorCode]
) as well as the generic # type: ignore
.
1 Answer
Reset to default 3Pyright has reportUnnecessaryTypeIgnoreComment
, which flags unnecessary # type: ignore
comments as errors.
To enable this check, add the following to your pyrightconfig.json
:
{
"reportUnnecessaryTypeIgnoreComment": "error"
}
Source:
Pyright Documentation - Type Check Diagnostics Settings
reportUnnecessaryTypeIgnoreComment
[boolean or string, optional]: Generate or suppress diagnostics for a# type: ignore
or# pyright: ignore
comment that would have no effect if removed. The default value for this setting is"none"
.
本文标签: pythonHow to check if pyright ignore comments are still requiredStack Overflow
版权声明:本文标题:python - How to check if `pyright: ignore` comments are still required? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744736590a2622367.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论