Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

Transcrypt not able to translate addict.py correctly : Creates circular dependency

Open sandeep-gh opened this issue 3 years ago • 1 comments

Transcrypt runs without error and produces output when ran over addict.py (a library on top of Dict, that uses some python dunder function hooks to make dictionary operations via class/object access patterns). I am using this https://github.com/sandeep-gh/addict fork.

Transcrypt compiles addict and reports no error. However, the generated javascript has no code corresponding to addict functions and it seems to have created a recursive definition which breaks rollup bundler (see Circular Dependency) Attached below is the relevant snippet of the generate addict.js.

'use strict';
import {
...
...
...
} from "./org.transcrypt.__runtime__.js";
import {
    Dict as Addict
} from "./addict.js";
import {
    Dict,
    walker
} from "./addict.js";
export {
    walker,
    Dict,
    Addict
};
....

The import line seems to be creating a circular dependency since within addict.js we are saying import Dict from addict.js. Are libraries like addict.py not transcryptable? Any high level idea how to debug/fix would be great.

sandeep-gh avatar Apr 28 '22 03:04 sandeep-gh

I created a module to test this and to get around some namespace confusion, I changed the import in my test from

from addict import Dict

to

from addict.addict import Dict

and bypassed the addict/__init__.py module. And while this got around one problem, Transcrypt wouldn't process the library anyway:

$ transcrypt --nomin --verbose addict_test.py

Error while compiling (offending file last):
	File 'addict_test.py', line 1, at import of:
	File 'addict.addict', line 35, namely:
	
	Built in function 'super' with arguments not supported

Aborted

It appears that the addict library has a few lines of Python code that Transcrypt is unable to process in its current form.

JennaSys avatar Aug 06 '24 07:08 JennaSys