Infinite recursion in generate_c_type_stub when an a type's attr has the same name as its parent
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
While trying out stubgen for the first time on a C(++)-extension module I get a 'RecursionError: maximum recursion depth exceeded' due to infinite recursion.
To Reproduce
conda create --name stubs python=3.9 --channel conda-forge --channel bioconda
conda install pyopenms mypy
stubgen -p pyopenms
Expected Behavior
No error. If I add a if (attr != class_name): here
https://github.com/python/mypy/blob/master/mypy/stubgenc.py#L361
it runs through.
BTW: You might also need to increase the timeout here: https://github.com/python/mypy/blob/master/mypy/moduleinspect.py#L165
No clue why it is so short.
Actual Behavior
Traceback (most recent call last):
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 367, in generate_c_type_stub
generate_c_type_stub(module, attr, value, types, imports=imports, sigs=sigs,
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 367, in generate_c_type_stub
generate_c_type_stub(module, attr, value, types, imports=imports, sigs=sigs,
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 367, in generate_c_type_stub
generate_c_type_stub(module, attr, value, types, imports=imports, sigs=sigs,
[Previous line repeated 989 more times]
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 356, in generate_c_type_stub
generate_c_function_stub(module, attr, value, methods, imports=imports,
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 182, in generate_c_function_stub
inferred = infer_sig_from_docstring(docstr, name)
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubdoc.py", line 232, in infer_sig_from_docstring
for token in tokens:
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/tokenize.py", line 525, in _tokenize
pseudomatch = _compile(PseudoToken).match(line, pos)
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/tokenize.py", line 99, in _compile
return re.compile(expr, re.UNICODE)
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/re.py", line 252, in compile
return _compile(pattern, flags)
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/re.py", line 292, in _compile
flags = flags.value
File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/types.py", line 178, in __get__
return self.fget(instance)
RecursionError: maximum recursion depth exceeded
Your Environment
- Mypy version used: 0.931
- Mypy command-line flags: -p pyopenms
- Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.9.9
- Operating system and version: macOS 10.15.4
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in mypy/stubgenc.py bei generate_c_type_stub an der gemeldeten Zeile und reproduziere das Problem anschließend mit stubgen -p pyopenms unter Verwendung der angegebenen Umgebung. Verfolge, wie ein Attribut mit demselben Namen wie sein übergeordnetes Element behandelt wird; als erledigt gilt die Aufgabe, wenn der Befehl ohne RecursionError abgeschlossen wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 50/100