millions-tailor-16868
10/23/2024, 9:42 AMfrom mod1 import submodule1; submodule1.class1()
to work but getting AttributeError: module submodule1 has no attribute class1
I do have __init__.py
files everywhere.
Wondering how I can avoid populating the __init__.py
files with from . import class1, class2, etc.
(which isn't a sustainable option) to prevent this error? I've understood this to be due to some type of lazy-loading - the import commands actually seem to work fine when attaching the debugger. Thanks in advance!better-van-82973
10/23/2024, 5:40 PMsubmodule1
a file or a directory? If it’s a file, then you should be able to import the class; Pants only models targets as low as file level. If it’s a directory, then I wonder how you’d plan to import directly from submodule1
without using __init__.py
?millions-tailor-16868
10/23/2024, 7:10 PMsubmodule1
is a directory. I was not aware of the Pants limitation that it only can target to file level, that's tricky. Don't suppose there's any known configuration around that?better-van-82973
10/23/2024, 7:24 PMmillions-tailor-16868
10/23/2024, 7:51 PM__init__.py
.
Thank you for bearing with me here! I'll assess my options in trying to support this in a maintainable way.