[mypyc] singledispatch made outside the main namespace
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 20.6k
- Forks
- 3.3k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Mypyc cannot compile if there's a singledispatch function defined outside the main namespace, for example in the body of a function or class.
To Reproduce
- Make a file with the following contents
from __future__ import annotations
from functools import singledispatch, _SingleDispatchCallable
from typing import Any
def outer() -> _SingleDispatchCallable:
@singledispatch
def inner(obj: object) -> Any:
return 2
return inner
- Compile with
mypyc
Actual Behavior
Traceback (most recent call last):
File "mypyc/irbuild/builder.py", line 176, in accept
File "mypy/nodes.py", line 831, in accept
File "mypyc/irbuild/visitor.py", line 123, in visit_decorator
File "mypyc/irbuild/function.py", line 86, in transform_decorator
File "mypyc/irbuild/function.py", line 312, in gen_func_item
File "mypyc/irbuild/function.py", line 351, in gen_func_ir
src/.../mwe.py:8: KeyError: <mypy.nodes.FuncDef object at 0x10a7bfb80>
The error occurs at the location of the @singledispatch.
Your Environment
- Mypy version used: '0.950'
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: Python 3.10.4
- Operating system and version: macOS Monterey 12.5.1
https://github.com/python/mypy/issues/13613#tasklist-block-c661a68b-595f-4b41-98a7-bf6bcaf6e3d9
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.
Piste de recherche
Reproduisez l’échec avec l’exemple imbriqué fourni utilisant singledispatch et mypyc. Commencez dans mypyc/irbuild/visitor.py, à visit_decorator, puis suivez transform_decorator, gen_func_item et gen_func_ir dans mypyc/irbuild/function.py. C’est terminé lorsque mypyc compile l’exemple sans le KeyError signalé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100