metaclass and new style generics do not work.
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
Piste de recherche
Reproduisez le crash avec le modèle Django générique présenté, la métaclasse, la configuration de mypy 2.3 et le traceback. Commencez dans mypy/semanal.py autour de analyze_func_def et defer, puis suivez le chemin du visitor depuis mypy/nodes.py. Le travail est terminé lorsque l’exemple ne lève plus d’erreur interne et que mypy fournit un résultat exploitable pour la classe.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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".
- Langage dominant
- Python
- Étoiles
- 20.6k
- Forks
- 3.3k
- Merge moyen
- 1 j 18 h
- PR mergées (30 j)
- 54
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python/mypy
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
bug topic-configuration topic-error-reporting
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Toutes les issues de python/mypy
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
zostera/django-bootstrap4#894 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
use-agent-os/agent-os#3276 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
zilliztech/memsearch#759 ·