pyanalyze icon indicating copy to clipboard operation
pyanalyze copied to clipboard

Support `# type: ignore`

Open JelleZijlstra opened this issue 3 years ago • 9 comments

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.

JelleZijlstra avatar May 14 '21 16:05 JelleZijlstra

Hey @JelleZijlstra, Can I work on the issue please??

Bhavay-2001 avatar Nov 17 '21 10:11 Bhavay-2001

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.

erezsh avatar Nov 17 '21 11:11 erezsh

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.

Bhavay-2001 avatar Nov 17 '21 13:11 Bhavay-2001

I'm a visitor here too. Let's see what the maintainer has to say.

erezsh avatar Nov 17 '21 14:11 erezsh

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.

JelleZijlstra avatar Nov 17 '21 14:11 JelleZijlstra

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??

Bhavay-2001 avatar Nov 18 '21 06:11 Bhavay-2001

We already check for # static analysis: ignore. This issue is about adding support for # type: ignore, which would work the same way.

JelleZijlstra avatar Nov 18 '21 13:11 JelleZijlstra

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

Bhavay-2001 avatar Nov 18 '21 16:11 Bhavay-2001

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.

JelleZijlstra avatar Nov 18 '21 16:11 JelleZijlstra