Skip to content

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

Open
@SWu

Description

@SWu

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions