Better error reporting for unavailable version or platform specific stub features

Open
#2,898 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
compilers

Research direction

Start with build.py: State.init() and the find_module call that searches manager.lib_path, then inspect default.py: PYTHON3_version and default_lib_path. Determine how unavailable or older platform-specific stubs should be reported and whether Python 3.6 belongs in the search paths. Done means the behavior clearly alerts users when the selected stub is unavailable or older, with the version-search behavior matching the supported Python versions.

Written by the indexing model from the issue text.

Description

feature priority-1-normal topic-usability

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.

Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 18h
Merged PRs (30d)
54

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.