You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix linting errors and add runtime import guidelines
- Fixed struct converter validation to properly reject complex cases with special characters
- Updated test expectations to match new struct conversion behavior where structs are converted to dictionaries
- Fixed runtime import in test_cursor.py by moving to top-level imports
- Fixed duplicate imports and line length issues in test files
- Added comprehensive import guidelines to CLAUDE.md prohibiting runtime imports
- All lint checks (ruff, mypy) now pass
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,43 @@ The project supports different cursor implementations for various use cases:
32
32
33
33
### Code Style and Quality
34
34
35
+
#### Import Guidelines
36
+
**CRITICAL: Runtime Imports are Prohibited**
37
+
-**NEVER** use `import` or `from ... import` statements inside functions, methods, or conditional blocks
38
+
-**ALWAYS** place all imports at the top of the file, after the license header and module docstring
39
+
- This applies to all files: source code, tests, scripts, documentation examples
40
+
- Runtime imports cause issues with static analysis, code completion, dependency tracking, and can mask import errors
41
+
42
+
**Bad Examples:**
43
+
```python
44
+
defmy_function():
45
+
from some_module import something # NEVER do this
46
+
import os # NEVER do this
47
+
if condition:
48
+
from optional import feature # NEVER do this
49
+
```
50
+
51
+
**Good Examples:**
52
+
```python
53
+
# At the top of the file, after license header
54
+
from__future__import annotations
55
+
56
+
import os
57
+
from some_module import something
58
+
from typing import Optional
59
+
60
+
# Optional dependencies can be handled with TYPE_CHECKING
61
+
from typing importTYPE_CHECKING
62
+
ifTYPE_CHECKING:
63
+
from optional import feature
64
+
65
+
defmy_function():
66
+
# Use imported modules here
67
+
return something.process()
68
+
```
69
+
70
+
**Exception for Optional Dependencies**: The PyAthena codebase does use runtime imports for optional dependencies like `pyarrow` and `pandas` in the main source code. However, when contributing new code or modifying tests, avoid runtime imports unless absolutely necessary for optional dependency handling.
0 commit comments