python / python/mypy

--bazel not using relative path in cache files for imports

Open
#16,996 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Report

if i create a python file file_a.py and a file file_b.py and i make file_b import file_a and i the run mypy --bazel file_b.py, then the paths in the meta.json and data.json files are relative in the cache files for file_b but absolute in cache files for file_a. I would expect mypy to use relative paths everywhere in bazel mode.

If I run directly on file_a (mypy --bazel file_a.py) i get relative paths in the cache files for file_a.

To Reproduce

Create file_a.py and file_b.py as described above, run mypy --bazel file_b.py.

Expected Behavior

Relative paths in all produced cache files. Also same hash and interface hash in the cache files for file_a produced by running on file_b that imports file_a, as if I had run directly on file_a.

Actual Behavior

Absolute path on cache files for imports. Also differing hash and interface hash of the cache files, if run on as an import vs. run on directly.

Your Environment

  • Mypy version used: 1.8.0 (Same behavior with other versions)
  • Mypy command-line flags: --bazel
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.11 (Same behavior with other versions)

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

Reproduce the issue with file_a.py importing file_b.py and run mypy --bazel file_b.py, then compare the meta.json and data.json cache files with those produced by running directly on file_a.py. Done means imported-file caches use relative paths and have the same hash and interface hash as direct-run caches.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.