Skip to content

Errors in followed imports cause crash without a way to ignore unless import following is entirely disabled #8688

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

Open
SWu opened this issue Apr 16, 2020 · 1 comment

Comments

@SWu
Copy link

SWu commented Apr 16, 2020

I think related to #6897 which was closed, but I often want to enable type checking on a module that imports a number of 3p packages that I have no control over.

However, I am finding that the import-following behavior for mypy is quite sensitive to things that I can't really control or easily ignore. I would expect that --follow-imports=silent would gracefully degrade in situations where this happens, but I find many cases where a stray comment (e.g. # type: some comment that's not actually a type specification) will cause a syntax error that causes the whole execution to error, and I can't find a way to ignore it without completely disabling --follow-imports.

I've encountered this with stray comments in tensorflow, for example. Is there any way to more gracefully fallback and recover from these kinds of errors in mypy? Or at least allow more fine-grained control on import following to not fail on syntax errors for specific external modules?

@SWu
Copy link
Author

SWu commented Apr 17, 2020

I found that the only way (apart from --follow-imports=skip) to ignore such errors in followed imports is to add a block for each:

[mypy-broken_package.*,other_broken_package.*]
ignore_errors = true
follow_imports = skip

However, the description of the silent option says that it "behaves in the same way as normal but will additionally suppress any error messages." However, it doesn't appear to be suppressing errors unless I explicitly configure each broken package as above, so either this is a bug, or that description should be clarified to describe when it will or won't skip errors in followed imports.

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

1 participant