Hi, is it possible to figure out the source root for a given python module, if you have list of source roots and modules?
e
enough-analyst-54434
02/26/2023, 3:43 PM
That's exactly what dependency inference does.
h
happy-kitchen-89482
02/26/2023, 4:10 PM
Do you have the module as a filesystem path or as a dotted import string?
happy-kitchen-89482
02/26/2023, 4:11 PM
I'm assuming the latter?
r
refined-addition-53644
02/26/2023, 4:32 PM
The latter.
h
happy-kitchen-89482
02/26/2023, 9:10 PM
And you're doing this in a plugin? Then yeah take a look at dep inference implementation, which maps modules to source paths, and then it's easy to map source paths to their source roots.