metaclass and new style generics do not work.
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
示されている汎用 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.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/mypy のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug topic-configuration topic-error-reporting
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
OpenHands/extensions#626 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
CSCfi/sd-search-api#39 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
StevenBlack/hosts#3255 ·