python / python/mypy

feat: Allow `-` in module name discovery

Open
#14,660 0 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

Can we allow - in module name discovery in https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules
with a flag allow_all_module_names or something

such that we can do:

For example, say your directory tree consists solely of src/namespace-pkg/mod.py. If you run the following command, mypy will correctly associate mod.py with namespace-pkg.mod:

 MYPYPATH=src mypy --namespace-packages --explicit-package-bases .

Pitch

This option is needed to circumvent the Duplicate module names. I want to treat everything as a module also if technically the name is not consistent with a python module. Could we make that more agnostic?

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 the module-mapping documentation linked in the issue and reproduce the shown MYPYPATH/mypy command using a namespace-pkg directory. Determine how a flag such as allow_all_module_names should affect hyphenated module names and the Duplicate module names case. Done should include an agreed option behavior and coverage for the documented example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.