metaclass and new style generics do not work.
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
使用所示的泛型 Django 模型、元類、mypy 2.3 設定和 traceback 重現當機。先從 mypy/semanal.py 中 analyze_func_def 和 defer 附近開始,接著從 mypy/nodes.py 追蹤 visitor 路徑。當該範例不再引發內部錯誤,且 mypy 為該類別回報可用的結果時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Bug Report
mypy fails with (modern and old) generics and metaclass, the whole application crashes.
To Reproduce
create a class like:
class AbstractModelMeta(ABCMeta, type(models.Model)):
"""
A Django model and Python abstract class
https://gist.github.com/gavinwahl/7778717
"""
pass
class SomeClass[TAttachment: Something](models.Model, metaclass=AbstractModelMeta):
@abstractmethod
def send_something(self) -> None:
"""
Send a notification to the original sender of a classification record that their classification record
has or has not been processed in AP Automation
"""
pass
The traceback is:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 2.3.0
Traceback (most recent call last):
File "<frozen runpy>", line 203, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "mypy/semanal.py", line 7732, in accept
File "mypy/nodes.py", line 1165, in accept
File "mypy/semanal.py", line 991, in visit_func_def
self.analyze_func_def(defn)
File "mypy/semanal.py", line 1036, in analyze_func_def
self.defer(defn)
File "mypy/semanal.py", line 7333, in defer
assert not self.final_iteration, "Must not defer during final iteration"
AssertionError: Must not defer during final iteration
src/isp/invoice/classification/models/base/base_classification_record.py:31: note: use --pdb to drop into pdb
Expected Behavior
I expect mypy to correctly understand this. or at least not choke on this.
Actual Behavior
This reports a failure:
error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Your Environment
- Mypy version used: 2.3
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini(and other config files): from toml file:
[tool.mypy]
python_version = "3.12"
plugins = ["mypy_django_plugin.main"]
ignore_missing_imports = true
exclude = ["migrations/", "130192/", "000000/", "130344/"]
mypy_path = "src"
[tool.django-stubs]
django_settings_module = "isp.platform.conf.dev"
- Python version used: 3.14.6
I also tried to tell mypy to ignore this file, but when I add it to the "exclude" everything that refers this breaks. And if I try to ignore it any other way it seems to constantly report this error. Is there a way to tell mypy to ignore a file, and manually say "hey this type should be considered "Any".
- 主要語言
- Python
- 星號
- 20.7k
- 分支
- 3.3k
- 平均合併
- 1 天 16 小時
- 30 天內合併 PR
- 96
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/mypy 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
`stubgen --inspect-mode` crashes with `AttributeError on PEP 604 union syntax (X | Y)` *(mypy 2.1.0)*可能已有人在做 @ayushdoesdev 於 68 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
Inconsistent description of `strict_optional`可能已有人在做 @Joosboy 於 84 天前認領。 未關閉documentation
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
Cannot set `output` in `mypy.ini`可能重新可做 關聯的 PR 已關閉且未合併。 未關閉bug topic-configuration topic-error-reporting
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
bug topic-attrs
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
相似的 Issue
-
needs triage
難度 2/5 1-3 小時 新手友好度 83/100
darnitdevorg/darnit#587 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
維護者通常 1 天內回覆
-
accessibility good first issue
難度 1/5 1-3 小時 新手友好度 92/100
維護者通常 1 天內回覆
-
llm translation
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
bug bug-hunt
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆