pyanalyze
pyanalyze copied to clipboard
Support `# type: ignore`
For compatibility, pyanalyze should support # type: ignore
in addition to # static analysis: ignore
. Error code-specific ignores should still work the same way. The functionality for using a custom ignore comment should not accept # type: ignore
.
This can be implemented mostly in node_visitor.py
.
Hey @JelleZijlstra, Can I work on the issue please??
What is the approach here? Are you planning to attach the comments to the AST? (iirc the ast module doesn't do that on its own)
If it helps, I have some code that does exactly that, and I can clean it up and post it.
Hey @erezsh, I'm new to this repo , I don't know how to work on this but surely with some guidance will be able to solve it.
I'm a visitor here too. Let's see what the maintainer has to say.
Thanks for offering to work on this!
I think it can be implemented basically by having the current code that checks for # static analysis: ignore
also check for # type: ignore
. This is done simply by substring matching on the text of the program.
Edge cases to consider:
- The error codes warning about unused ignores and ignores without a specific error code should still work.
- The functionality for making an error accept a different error string should still work and should not accept
# type: ignore
.
Hey @JelleZijlstra , thanks for replying. Soo as per your comment, you want us to make a program which checks for #static analysis: ignore ?? Soo basically it would be a string matching algorithm??
We already check for # static analysis: ignore
. This issue is about adding support for # type: ignore
, which would work the same way.
Hey @JelleZijlstra , thanks for replying. Could you please help me on how to start or in what direction to think for the same?? Like how should I proceed on working on this issue. Thanks
I would clone the repo, look for the places that implement # static analysis: ignore
(use grep), then extend the logic there to also cover # type: ignore
.