memestra icon indicating copy to clipboard operation
memestra copied to clipboard

Memestra doesn't work if you're using __init__ imports

Open marimeireles opened this issue 5 years ago • 6 comments

I found a case where memestra doesn't work, but I suppose we want it to work:

If you're importing something from init like in here:

https://github.com/numpy/numpy/blob/41e254f96e8d5bd558d2edbf8b198eb4143e8b74/numpy/init.py#L155

for example, memestra won't return anything.

A reproducible example of what I mean would be running a file init_test.py with the command memestra init_test.py --decorator=decoratortest.deprecated that contains:

from tests.misc import foo

foo()

in memestra home and adding this line from some_module import foo to the __init__.py in tests/misc.

marimeireles avatar May 22 '20 10:05 marimeireles

This looks like a case where we want the import to be recursive, right? If that's so it would be good to have the generic opt-in recursive import mechanism, then use it for __init__.py

serge-sans-paille avatar May 25 '20 21:05 serge-sans-paille

Yeah, so I thought, but it's not working with the recursion I implemented here https://github.com/QuantStack/memestra/pull/9, that's why I opened an issue to keep track and explore it later. :) Please let me know if I can assist you with anything regarding these recursion issues.

marimeireles avatar May 27 '20 17:05 marimeireles

Yeah, I think what I meant here was that I was having a problem with relative imports, that are still not working. Maybe we should do this before tagging a release. I can give it a try :)

marimeireles avatar Jun 11 '20 08:06 marimeireles

Sure, go ahead!

serge-sans-paille avatar Jun 11 '20 11:06 serge-sans-paille

I think it'd be better to merge your PR first? Or you don't think it'd make much difference?

marimeireles avatar Jun 11 '20 21:06 marimeireles

I think it's better to merge my PR first, but it shouldn't prevent you from starting to work on that issue :-)

serge-sans-paille avatar Jun 12 '20 10:06 serge-sans-paille