-
-
Notifications
You must be signed in to change notification settings - Fork 31
Fix unable to find root namespace #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few questions just to make sure I understand correctly. Could add your answers as comments in the code too, to the attention of future readers (you and I included 😄)?
So, if I get it right, it's doing the same thing as before, except better, because it not only tries the top package name, but all the possible parts concatenation down to the before-last part? And you also try to import the module if it's not already loaded in sys.modules.
If yes, then it looks good. Do the tests pass? Currently GitLab does not support triggering CI for PRs from forks, sorry about that... I might need to setup GitHub Actions or Azure devops or whatever this is instead 😕
In the related issue, you said that testing for native namespace packages would be a giant pain. Could you explain why? Is it because the tests folder has an __init__.py, which means to test native namespace package we would need to put it outside of this folder?
Finally, could you explain how this could break? You mention a nested module but I'm not sure to understand 😅 Maybe a folder tree example would help!
|
The nested |
|
This is definitely more readable! We always enforce the module is imported, and I guess it's not an expensive operation when it's already loaded, so it's fine. |
|
Alright, this looks great. Anything more you'd like to add? Also, do you mind if I squash the commits? I'm using the angular style, to ease the generation of the changelog. EDIT: oh, I forgot about the tests! Do you think you could write some? |
|
I'm trying to figure out how to build a test fixture since namespace packages have to be installed to get them to be located properly. |
|
Nice! The |
|
Hmmm. Actually no, that should have been covered since i'm attempting to load a namespace directory. Let me play with test a bit more. |
|
Ok. That was just a bad test. I've updated it to actually check the I think this is ready to merge now. |
|
I can setup pushing to codecov if you setup the account and add the codecov token to github secrets for this repo. I just need to know the name of the secret to reference it in the workflow. |
|
Not a fan of codecov 😕 (generally not a fan of third-party web services) If we can get a badge from GitHub workflow to show coverage percent in README, it's good enough for me! If not, well... it's fine. Not really important. Anyway, thank you very much @shyamd! I really appreciate your work on this. |
|
Thanks again! 🎉 |
This fixes an issue finding the relative path when the root package is a namespace package. This is likely to break if the namespace package is nested in the module like
my_package.pluginsand you want to document something that lives in that plugins namespace.