Skip to content

Commit 547ec88

Browse files
fedorovclaude
andcommitted
fix: lazy-import google-cloud-bigquery in idc_index_data_manager
Move the bigquery import into __init__ and use TYPE_CHECKING for type annotations, so tests that only use the static parsing methods can import the module without google-cloud-bigquery installed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8e69de3 commit 547ec88

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

scripts/python/idc_index_data_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
import os
66
import re
77
from pathlib import Path
8+
from typing import TYPE_CHECKING
89

910
import pandas as pd
10-
from google.cloud import bigquery
11+
12+
if TYPE_CHECKING:
13+
from google.cloud import bigquery
1114

1215
logging.basicConfig(level=logging.DEBUG)
1316
logger = logging.getLogger(__name__)
@@ -18,6 +21,8 @@ def __init__(self, project_id: str):
1821
"""
1922
Initializes the IDCIndexDataManager using the Google Cloud Platform project ID.
2023
"""
24+
from google.cloud import bigquery # noqa: PLC0415
25+
2126
self.project_id = project_id
2227
self.client = bigquery.Client(project=project_id)
2328
logger.debug("IDCIndexDataManager initialized with project ID: %s", project_id)

0 commit comments

Comments
 (0)