jepperaskdk / pydoctest

Python docstring signature verification
MIT License
20 stars 3 forks source link

Relative imports seem to break the program #45

Open vishnu-chopra opened 1 year ago

vishnu-chopra commented 1 year ago

I have a folder with 2 files types.py and common.py. types.py Imports from common.py

from .common import x, y, z

I get the following error: Failed to load module dependant module: No module named 'types.common'; 'types' is not a package For the time being I have put a workaround to maintain the package behaviour and satisfy pydoctest, however this seems like a bug IMO, please let me know if I am mistaken.

try:
    from .common import x,y,z
except:
    from common import x,y,z
jepperaskdk commented 1 year ago

Thanks for submitting this! I haven't used relative imports much myself, so it may very well be a bug in pydoctest.

I don't know if types.py is perhaps clashing with the builtin types module, since if I rename it to e.g. types_test.py, I instead get ImportError('attempted relative import with no known parent package'), similar to running python3 types_test.py. I'll see if I can find the problem.

jepperaskdk commented 3 months ago

I never got around to look further into this. Can someone create a minimal reproduce of the issue?