python / python/mypy

(🐞) crash with `--pretty` from attrs raising an error in the wrong file

Open
#17,535 19 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

> git clone https://github.com/DataDog/dd-trace-py
> cd dd-trace-py
> pip install -e .
> pip install mypy
> mypy --strict --check-untyped-defs | grep threading.py
ddtrace/profiling/collector/threading.py:25: error: Need type annotation for "recorder"  [var-annotated]
ddtrace/profiling/collector/threading.py:29: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
ddtrace/profiling/collector/threading.py:316: error: Need type annotation for "tracer"  [var-annotated]
> mypy --strict --check-untyped-defs --pretty
...
  File "mypy/main.py", line 100, in main
  File "mypy/main.py", line 182, in run_build
  File "mypy/build.py", line 192, in build
  File "mypy/build.py", line 266, in _build
  File "mypy/build.py", line 2942, in dispatch
  File "mypy/build.py", line 3340, in process_graph
  File "mypy/build.py", line 3465, in process_stale_scc
  File "mypy/errors.py", line 915, in file_messages
  File "mypy/errors.py", line 885, in format_messages
IndexError: list index out of range

threading.py:316: error, threading only has 43 lines in it.

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 crash with mypy --strict --check-untyped-defs --pretty after following the setup commands in the issue. Start in mypy/errors.py, especially format_messages and file_messages, and compare the reported location with the errors from ddtrace/profiling/collector/threading.py; done means --pretty completes without an IndexError and reports valid locations.

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
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.