python / python/mypy

(🐞) error code that is enabled in the config file can't be disabled on the CLI (with `--disable-error-code`)

未关闭
#16,628 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug topic-configuration
主要语言
Python
星标
20.6k
派生
3.3k
平均合并
1 天 18 小时
30 天内合并 PR
54

描述

I think it would be intuitive for commandline arguments to override config file options, but the way that enable/disable-error-code works isn't.

pyproject.toml

[tool.mypy]
enable_error_code = "operator"
> mypy --disable-error-code operator -c "1 + ''"
test.py:1: error: Unsupported operand types for + ("int" and "str")  [operator]
Found 1 error in 1 file (checked 1 source file)

The docs specify how these flags interact with themselves, but don't mention the ones in the config file.

--enable-error-code
This flag allows enabling one or multiple error codes globally. See [Error codes](https://mypy.readthedocs.io/en/stable/error_codes.html#error-codes) for more information.

Note: This flag will override disabled error codes from the [--disable-error-code](https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-disable-error-code) flag.

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先追踪 mypy 如何将 pyproject.toml 中的 enable_error_code 和 disable_error_code 与命令行选项结合起来。使用 --disable-error-code operator 重现该示例,然后为配置与 CLI 的组合添加覆盖测试。当 CLI 选项能够抑制已配置的错误代码,并且文档解释了这一优先级时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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