python / python/mypy

Support glob patterns when configuring `mypy_path`

Open
#9,965 4 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Feature

Support the glob patterns * and ** in the mypy_path configuration.

Should work the same way as it does for the files configuration.

Pitch
I have a monorepo, with a bunch of python libraries located in a directory called libs.
All packages are namespace packages with the same namespace, but they are kept in their own directory inside of the libs directory:

repository_root
│
└───libs
│   └───pkg-a
│   |    └───namespace
│   |
│   └───pkg-b
│   |    └───namespace
│   |
│   └───pkg-c
│        └───namespace
│
└───mypy.ini

The mypy_path declaration in my mypy.ini looks something like this (but with dozens of packages):

mypy_path = $MYPY_CONFIG_FILE_DIR/libs/pkg-a:
    $MYPY_CONFIG_FILE_DIR/libs/pkg-b:
    $MYPY_CONFIG_FILE_DIR/libs/pkg-c:

It would be very convenient to use a glob pattern like this instead:

mypy_path = $MYPY_CONFIG_FILE_DIR/libs/*

It's more concise, and would avoid potential problems with forgetting to include a newly added package in mypy_path.

Thanks for a great tool!

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 by tracing how glob patterns are supported for the files configuration and identify the corresponding mypy_path parsing and resolution entry points. Extend the behavior so * and ** work there too, then verify that the namespace-package monorepo example resolves all matching library directories.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
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.