Skip to content

Commit 66afab2

Browse files
Add all modules to pre-commit checks
1 parent c4d2a50 commit 66afab2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ci/pre-commit/check_optional_imports.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pathlib import Path
1111
from typing import List
1212

13-
CHECKED_MODULES = ["boto3", "botocore"]
13+
CHECKED_MODULES = ["boto3", "botocore", "pandas", "pyarrow", "keyring"]
1414

1515

1616
@dataclass(frozen=True)
@@ -33,6 +33,14 @@ def __init__(self, filename: str):
3333
self.filename = filename
3434
self.violations: List[ImportViolation] = []
3535

36+
def visit_If(self, node: ast.If):
37+
# Always visit the condition, but ignore imports inside "if TYPE_CHECKING:" blocks
38+
if getattr(node.test, "id", None) == "TYPE_CHECKING":
39+
# Skip the body and orelse for TYPE_CHECKING blocks
40+
pass
41+
else:
42+
self.generic_visit(node)
43+
3644
def visit_Import(self, node: ast.Import):
3745
"""Check import statements."""
3846
for alias in node.names:

0 commit comments

Comments
 (0)