KEMBAR78
Document how to selectively ignore specific imports · Issue #3476 · python/mypy · GitHub
Skip to content

Document how to selectively ignore specific imports #3476

@JukkaL

Description

@JukkaL

Currently mypy users often have to ignore all imports (--ignore-missing-imports) because mypy can't find stubs for a third party library module. Instead, we could provide an option to only ignore specific imports everywhere within a program.

Potential way to support this:

mypy --ignore-imports=sqlalchemy,frobnicator program.py

This would have a few benefits over --ignore-missing-imports:

  • It would be possible to have fine-grained control over ignored imports (without using a lot of # type: ignore comments).
  • It would be easy to guard against accidentally adding additional ignored dependencies.
  • Users might be more likely to contribute stubs for 3rd party libraries since it would be more obvious where this would be helpful. Once users start using --ignore-missing-imports, they lose a lot of visibility to which stubs are missing.
  • Mypy would be able to catch misspelled module names in import statements.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions