python / python/mypy

mypy evaluates `files` config property relative to current working directory iso config file location

Open
#18,809 0 comments 0 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

Bug Report

In https://github.com/python/mypy/pull/18482 support was added for walking up the file system to find the appropriate config file. I wanted to try this out, but ran into a problem.

The config file might contain a section files (and also exclude).
IMO the paths specified there should be considered relative to the location of the config file.

Instead mypy considers them relative to the current working directory (where mypy was invoked).
In order for the 'walk up' functionality to be useful the paths should be interpreted as relative to the config file location.

Actual Behavior

$ mypy
mypy: can't read file 'tests': No such file or directory

Your Environment

  • Mypy version used: 1.15
  • Mypy configuration options from mypy.ini (and other config files): files = tests

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

Review PR 18482 and the configuration handling for mypy.ini, especially the files and exclude options. Reproduce the failure from a subdirectory with files = tests, then trace how the config location and current working directory are used. Done means configured paths resolve relative to the config file and the behavior has regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
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.