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

Pycharm issue while importing APIC class #336

Closed
24Naman opened this issue Jan 18, 2018 · 7 comments
Closed

Pycharm issue while importing APIC class #336

24Naman opened this issue Jan 18, 2018 · 7 comments
Labels

Comments

@24Naman
Copy link

@24Naman 24Naman commented Jan 18, 2018

-> from mutagen.id3 import ID3, APIC

when APIC is imported from the package mutagen.id3, Pycharm issues an error "Unresolved reference 'APIC'" as it is not declared in the '__all__' variable.

@lazka

This comment has been minimized.

Copy link
Member

@lazka lazka commented Jan 18, 2018

What's in __all__ shouldn't matter here. My guess is that it can't detect the reference due to the code adding them with globals()[f] = ...

We could just list them all there explicitly (and add a test to the test suite that checks that all are there)

@lazka lazka added the enhancement label Jan 18, 2018
@24Naman

This comment has been minimized.

Copy link
Author

@24Naman 24Naman commented Jan 18, 2018

It was just a guess because when I checked the source it was not there and somebody has suggested that pycharm read all variable for imports

@lazka lazka closed this in abdc923 Jan 20, 2018
@lazka

This comment has been minimized.

Copy link
Member

@lazka lazka commented Jan 20, 2018

Thanks for the report. If there are other things PyCharm doesn't like please report them.

@rlindner81

This comment has been minimized.

Copy link

@rlindner81 rlindner81 commented Oct 8, 2019

I came across this issue today and I would not agree that this is a pycharm issue. It can resolve the origin of these imported classes just fine. The inspector gives a "weak" warning because it considers these classes protected and so they should not be accessed for regular usage.

This inspection warns if a protected member is accessed outside the class, a descendant of the class where it's defined or a module.

Going back to a PEP you can see why they would think that
https://www.python.org/dev/peps/pep-0008/#public-and-internal-interfaces

To better support introspection, modules should explicitly declare the names in their public API using the __all__ attribute. Setting __all__ to an empty list indicates that the module has no public API.

@lazka

This comment has been minimized.

Copy link
Member

@lazka lazka commented Oct 8, 2019

I think there is a misunderstanding here. This is not a pycharm issue, and these fields are/were public. They were just made public in a non-statically analyzable manner, which the commit fixed.

And as I stated above: "If there are other things PyCharm doesn't like please report them."

@rlindner81

This comment has been minimized.

Copy link

@rlindner81 rlindner81 commented Oct 8, 2019

Ah, you are right. I had not seen that you closed the issue via a commit that enables proper static analysis...

Still, as I wrote, an inspector (probably based on that PEP) still marks example code from your docs as slightly faulty.
https://mutagen.readthedocs.io/en/latest/user/id3.html
example

@lazka

This comment has been minimized.

Copy link
Member

@lazka lazka commented Oct 8, 2019

Ah, right, good point. I've created #397 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.