Skip to content

Better error reporting for unavailable version or platform specific stub features #2898

@pkch

Description

@pkch

When type-checking a python 3.6 file that contains from enum import auto, the latest build of mypy ( commit 0bb2d16 from master) complains: error: Module 'enum' has no attribute 'auto'. The reason is that build.py: State.__init__() finds the stub for enum using path = find_module(file_id, manager.lib_path); and the paths in manager.lib_path are something like

('.../typeshed/stdlib/3.4', .../typeshed/stdlib/3.3', '.../typeshed/stdlib/3', '.../third_party/3', '.../stdlib/2and3', '.../third_party/2and3')

It's understandable that stubs aren't yet available for the most recent library versions in typeshed, but I think mypy should perhaps warn the user about it to make it easier to figure out what the problem is. For instance, whenever a library stub used is for an older version, a warning could be logged?

Related to this is the fact that the default.py: PYTHON3_version is (3, 5); perhaps it should be updated to (3, 6)? As is, the default_lib_path doesn't even attempt to search in .../typeshed/stdlib/3.6 folder. (This wouldn't have helped in my case, since there's no enum.pyi in the 3.6 folder.)

Also related is #2897 that I just opened.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions