Avoiding cyclic imports, but how...?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 28/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, python
- Domain
- compilers
Research direction
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.
Written by the indexing model from the issue text.
Description
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?
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 218
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TranscryptOrg/Transcrypt
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
TranscryptOrg/Transcrypt#913 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
TranscryptOrg/Transcrypt#911 · 2 comments ·
-
IS: bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Difficulty 1/5 Under an hour Newbie friendliness 62/100
TranscryptOrg/Transcrypt#656 · 7 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 76/100
TranscryptOrg/Transcrypt#914 ·
All issues in TranscryptOrg/Transcrypt
Similar issues
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100