python / python/mypy

Error location show incorrect file.

Open
#16,175 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-0-high topic-usability
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Following up on issue https://github.com/HypothesisWorks/hypothesis/issues/3753: the failing example in that issue always shows the test.py file as the originating file, which is incorrect:

test.py:1139:50: error: Cannot use a covariant type variable as a parameter  [misc]

The file containing the failing type check is called from test.py.

To Reproduce

See the referenced issue: install Hypothesis and mypy using the mentioned versions, and run the example.

Expected Behavior

Error location should show the file that contains the failing type check.

Actual Behavior

Error location shows the file file that contains the call to the failing type check.

Your Environment

  • Mypy version used: 1.5.1
  • Mypy command-line flags: mypy --show-traceback --config-file pyproject.toml test.py
  • Mypy configuration options from pyproject.toml:
    
     [tool.mypy]
     # mypy_path =
     # exclude =
     show_error_codes = true
     show_column_numbers = true
     check_untyped_defs = true
     incremental = false
     strict_equality = true
     warn_return_any = true
     warn_redundant_casts = true
     warn_unreachable = true
     warn_unused_configs = true
     warn_unused_ignores = true
     disallow_untyped_calls = true
     disallow_untyped_defs = true
     disallow_incomplete_defs = true
     disallow_untyped_decorators = true
     disable_error_code = []
     
     [[tool.mypy.overrides]]
     module = [
     ]
     ignore_missing_imports = true
    
  • Python version used: python 3.10.13 (main, Aug 25 2023, 01:44:57) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin

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 reproduction in the referenced Hypothesis issue, using test.py, pyproject.toml, and the reported mypy command and versions. Trace how the failing type check's location is selected rather than the caller's location, then verify that the diagnostic identifies the file containing the failing check.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.