python / python/mypy

with -p or -m, error if the package name is not importable

Open
#12,763 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Feature

When the command line is issued specifying scan targets using -p or -m, verify that a package is importable under that name and fail if not.

Pitch

I was scanning two related packages using:
mypy --namespace_packages -p namesp.pkg1 -p namesp_pkg2
The second was a typo, the folder name for the (namespace) package that was a child of $PWD. I got error messages, but they were very confusing, about a file being found in two locations (where the "same" command line, as I thought, had worked properly just two days before). I didn't figure out it was a typo for quite some time.
But obviously, there is no package namesp_pkg2 and an error to that effect would have saved me some time.

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.

Research direction

Start with mypy's command-line handling for the -p and -m options and reproduce the example with a deliberately misspelled package name. Trace where scan targets are validated, then confirm that an unimportable package produces a direct error instead of confusing duplicate-file diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.