I'm working on a project in PyCharm and I have two files: connect.py and run.py. Both of these files are in the root of the project directory.
connect.py
"""Hello Analytics Reporting API V4."""
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
SCOPES = ['https://www.googleapis.com/auth/analytics.readonly']
KEY_FILE_LOCATION = 'client_secrets.json'
VIEW_ID = '123456' # My actual view ID is here
def initialize_analyticsreporting():
"""Initializes an Analytics Reporting API V4 service object.
Returns:
An authorized Analytics Reporting API V4 service object.
"""
credentials = ServiceAccountCredentials.from_json_keyfile_name(
KEY_FILE_LOCATION, SCOPES)
# Build the service object.
analytics = build('analyticsreporting', 'v4', credentials=credentials)
return analytics
run.py
import connect
# some more code here...
The first line, import connect
is greyed out:
When I hover over the greyed out text a popup 'unused import statement' appears with a clickable 'more actions' option:
This opens an 'inspection results' pane with an error warning. See screen for details.
The code inside of connect.py was initially at the top of run.py, I just wanted to separate into two scripts. When it was all in the same file the script ran fine. It's only when I've separated out into two files that this happened.
How can I import connect.py into run.py? Let me know if there are more details I should provide?