python / python/mypy

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

未关闭
#17,535 19 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

crash
主要语言
Python
星标
20.6k
派生
3.3k
PR 合并指标
PR 指标待抓取

描述

> 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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

按照 issue 中的设置命令操作后,使用 mypy --strict --check-untyped-defs --pretty 重现崩溃。从 mypy/errors.py 开始,重点查看 format_messagesfile_messages,并将报告的位置与 ddtrace/profiling/collector/threading.py 中的错误进行比较;当 --pretty 在没有 IndexError 的情况下完成,并报告有效位置时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。