Skip to content

Whitelisting skipped modules #2541

Closed
Closed

Description

@JukkaL

Currently when using --silent-imports (or the new alternative that is being worked on in #2513) mypy won't catch misspelled module names, and will silently accept them. Instead of skipping all modules that we can't find, another alternative would be to allow users to explicitly specify which modules don't exist or are missing a stub, and only skip imports of/from these modules.

A few ways this could be supported:

  1. Add a command line and config file option to enumerate skipped modules.
  2. Support partially-defined stubs through def __getattr__(name) -> Any: ... (defined in PEP 484). If this is defined for a stub, we should perhaps also allow arbitrary submodules to be imported. We could define local minimal stubs with only this __getattr__ definition for things for which there's no real stub.

I prefer option 2 since we already have a pretty large number of command-line options and this behavior is defined by PEP 484 (except for the behavior of submodules).

This is based on an issue reported by a user.

Activity

  1. msullivan commented on Apr 4, 2018

    @msullivan
    Collaborator

    This can be accomplished with per-module values for ignore_missing_imports/follow_imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions