Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

[2.4 regression] modules imported inside a method of an `ignore_errors` module aren't checked anymore

未關閉
#22,280 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@bniladridas 已經在處理了。

開始於 2026年10月25日。

  • #1 來自 @bniladridas —— 已關閉,未合併
  • #22285 來自 @ShahabAhmed01 —— 已關閉,未合併
  • #22298 來自 @bniladridas —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
63/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
python

研究方向

Start by reproducing the regression with the provided pkg modules and mypy.ini, comparing the reported 2.3.1 and 2.4.0 results. Trace how imports inside methods are handled when the importing module has ignore_errors = True; the issue names no mypy source file or test. Done means mypy still reports the incompatible assignment in pkg/b.py under the 2.4.0 configuration.

由索引模型根據 Issue 內容生成。

描述

bug topic-parser topic-stubtest

pkg/__init__.py:

# -- nothing to see here --

pkg/a.py:

class A:
    def f(self) -> None:
        import pkg.b

pkg/b.py:

x: int = "moo"

repro.py:

import pkg.a

mypy.ini:

[mypy]
[mypy-pkg.a]
ignore_errors = True

2.3.1

$ uvx --with="mypy==2.3.1" mypy repro.py
pkg/b.py:1: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 1 error in 1 file (checked 1 source file)

2.4.0

$ uvx --with="mypy==2.4.0" mypy repro.py
Success: no issues found in 1 source file

Numba runs stubtest with ignore_errors = True, so after upgrading mypy to 2.4.0 (in numba/numba#10887) this bug caused new failed to find stubs errors for modules that are only imported from within some method. The workaround is to set native_parser = False in the mypy.ini for now.

主要語言
Python
星號
20.7k
分支
3.3k
平均合併
1 天 18 小時
30 天內合併 PR
123

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

python/mypy 的其他 Issue

查看 python/mypy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。