Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore statement not working for some cases (import_failed) #699

Open
mflova opened this issue Oct 10, 2023 · 2 comments
Open

Ignore statement not working for some cases (import_failed) #699

mflova opened this issue Oct 10, 2023 · 2 comments

Comments

@mflova
Copy link
Contributor

mflova commented Oct 10, 2023

So far I found this strange behaviour when trying to silence some import_failed error codes. Here is a minimal example:

# Error not reported in this file -> OK
import a  # static analysis: ignore
# Error reported in this file -> NOK
from __future__ import annotations

import a  # static analysis: ignore
# Error not reported in this file -> OK
# static analysis: ignore
from __future__ import annotations

import a
@JelleZijlstra
Copy link
Contributor

The problem here is that import_failed is not reported at a particular line, because it doesn't happen while pyanalyze is visiting the file, but while it's trying to import it. If this error happens, it will essentially make it impossible for pyanalyze to check the rest of the file. I'm not sure that's something I should change, as it's an essential part of pyanalyze that it works by importing the file.

Your last example works because # static analysis: ignore on a line by itself at the beginning of the file ignores the entire file.

@mflova
Copy link
Contributor Author

mflova commented Oct 13, 2023

It makes sense. I do not think it is worth to change it then. Thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants