Skip to content
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

AttributeError - unlcear how to import a Class from a module #53

Closed
cforce opened this issue May 11, 2023 · 6 comments · Fixed by #55
Closed

AttributeError - unlcear how to import a Class from a module #53

cforce opened this issue May 11, 2023 · 6 comments · Fixed by #55

Comments

@cforce
Copy link

cforce commented May 11, 2023

unable to get followig imported https://github.com/rosomri/atlassian-python-api imported via

with httpimport.github_repo('rosomri', 'atlassian-python-api', ref='confluence_bugfix_export_pdf'):
import atlassian

Traceback (most recent call last):
File "C:\develop\git\scripts\collectors\confluence.py", line 213, in
confluence = connect_to_confluence(args.cf_url, args.cf_user, args.cf_token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\develop\git\scripts\collectors\confluence.py", line 48, in connect_to_confluence
return atlassian.Confluence(
^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'atlassian' has no attribute 'Confluence'

What i am doing wrong?

@operatorequals
Copy link
Owner

Hey @cforce 🙃
I really don't see what this happens in first glance.
Can you provide the version of the module you are using?

@cforce
Copy link
Author

cforce commented May 14, 2023

i am using the latest of everything

@rkbennett
Copy link
Contributor

rkbennett commented Jul 19, 2023

Sorry for being late to the party, but after looking through the code and what the results are of importing that repo (at least for me), it appears there was a bug introduced to the submodule logic when the refactor happened. Specifically the else statement was removed from this conditional https://github.com/operatorequals/httpimport/blob/master/httpimport.py#L439
This causes it to assume the __package__ attribute to be the full module name, which breaks relative imports on submodules which are 2nd level submodules (i.e. package.module). The else statement needs to be added back which sets the package attribute like this mod.__package__ = name.split('.')[0] though with the new code it would be pkg_name.

@cforce
Copy link
Author

cforce commented Jul 19, 2023

@rkbennett Would you provide a pull request with the fix, that would be great.

@operatorequals
Copy link
Owner

operatorequals commented Jul 19, 2023

I'm here to review and merge a PR (and cut a release), but it would take a bit more for me to develop the fix, as I currently am not into computers all that much!

Cheers @rkbennett for finding tje culprit, I didn't have the time and energy to debug.

@rkbennett
Copy link
Contributor

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants