Avoiding cyclic imports, but how...?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 28/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, python
- Ambito
- compilers
Direzione di ricerca
Start by reproducing the recursion error from the minimal mylib example using test.py and test.html, then inspect the generated JavaScript around the imports in mylib/a.py, mylib/b.py, mylib/examine.py, and mylib/init.py. Compare the Transcrypt output with CPython's behavior and determine whether cyclic imports can be supported or need a documented limitation and workaround.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi, I'm still trying to port a library that initially was written to run with PyJS to Transcrypt, and got into one more issue where I was not able to find any running solution. I am trying to describe the problem in a much simpler test case, which does exactly the same and runs in the same problem, a "too much recursion" message in the browser.
.
├── mylib
│ ├── a.py
│ ├── b.py
│ ├── examine.py
│ └── __init__.py
├── test.html
└── test.py
mylib/a.py:
from mylib import examine
class A(object):
def examine(self):
examine.examine()
mylib/b.py:
from mylib.a import A
class B(A):
pass
mylib/examine.py:
import mylib
def examine():
for key in dir(mylib):
print(key)
mylib/__init__.py:
from mylib.a import A
from mylib.b import B
import mylib.examine
The reason for the function examine() in mylib.examine is, that it both should be callable outise of A or in context of A, and it examines the contents of the mylib module, its objects and classes.
CPython compiles and runs this without compromise. The Transcrypt-generated output runs into an recursion error, because mylib.examine imports examine. According to issue #106, cyclic imports are a problem. So, surely, this is more a question how I have to style my code, but I can't find a solution right now... can this problem be solved in any way?
- Lingua principale
- Python
- Stelle
- 2.9k
- Fork
- 218
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TranscryptOrg/Transcrypt
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TranscryptOrg/Transcrypt#913 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
TranscryptOrg/Transcrypt#911 · 2 commenti ·
-
IS: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
TranscryptOrg/Transcrypt#656 · 7 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
TranscryptOrg/Transcrypt#914 ·