Reputation: 1287
I have a flask app that I'm developing in PyCharm on MacOS.
When I try to import the flask current app like this:
from flask import current_app as app
I get an inspection error: Unresolved reference 'current_app'
, but when I run the the project I get no runtime errors.
If I "import" the current app like this:
import flask
app = flask.current_app
then PyCharm is happy.
I have the same problem with local imports. How can I fix this.
Upvotes: 2
Views: 2799
Reputation: 11
I tried the solution that the user nobody suggested. However, the file __init__.py was not within the Registered Patterns in the Text file type.
I searched lot of similar questions and also tried their suggestions but nothing worked. So I came up with the idea to add __init__.py into the --> Settings | Editor | File Types | Python | Registered patterns
And the unresolved reference error is now solved.
Upvotes: 1
Reputation: 1287
I opened a ticket with JetBrains support, and after a long investigation they found the issue.
Somehow my __init__.py
files got associated with text files, and that broke the resolver. I fixed it by going to Settings | Editor | File Types | Text | Registered patterns and deleting __init__.py
from the registered patterns.
Thank you JetBrains for the great support!
Upvotes: 3