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
Specify single blank lines between __future__, stdlib, third-party,
local, relative, and TYPE_CHECKING blocks, plus two blank lines after
imports before module body content.
Co-authored-by: Cursor <cursoragent@cursor.com>
-**Maintainability**: Clear separation between stdlib, third-party, and internal code
644
646
645
647
### Import Grouping Rules
646
-
-**Group by source**: Standard library, third-party, internal
647
-
-**Separate groups**: Use blank lines between groups (one blank line is sufficient)
648
+
-**Group by source**: `__future__` → standard library → third-party → internal/local (absolute) → relative local → `TYPE_CHECKING`
649
+
-**Separate groups with single blank lines**: Put **exactly one blank line** between each import block listed above. Do not run adjacent groups together (e.g. never place `from typing import ...` immediately above `from django...` without a blank line between them).
650
+
-**Two blank lines after imports**: After the final import block (including a trailing `if TYPE_CHECKING:` block when present), put **two blank lines** before the next module content (`__all__`, module-level constants, type aliases, or class/function definitions).
648
651
-**Group comments**: **RECOMMENDED** - Add comments identifying each import group for clarity (e.g., `# Standard library imports (alphabetical)`, `# Third-party imports (alphabetical)`, `# Internal imports (alphabetical)`)
-**Relative vs absolute**: Use absolute imports for cross-package imports, relative imports for same-package modules. **Within internal imports group**: Absolute imports come first, then relative imports (both alphabetically ordered within their respective subgroups)
653
+
-**Relative vs absolute**: Use absolute imports for cross-package imports; use relative imports for same-package modules. **Order**: absolute internal/local imports first, then relative local imports (each subgroup alphabetically ordered). Do not mix third-party imports into the local/relative groups.
651
654
-**Organize large import lists**: For large import lists (e.g., many query constants), use comments to group related imports for readability
652
655
-**Pattern**: `# Group name` comment before related imports
653
656
-**When to use**: When importing 10+ items from a single module, especially when they can be logically grouped
@@ -674,7 +677,7 @@ import inspect
674
677
import json
675
678
import os
676
679
from pathlib import Path
677
-
from typing import Any, Literal, LiteralString
680
+
from typing importTYPE_CHECKING, Any, Literal, LiteralString
678
681
from uuid importUUID
679
682
680
683
# Third-party imports (alphabetical)
@@ -684,7 +687,28 @@ from dana.core.agent.star_agent import STARAgent
0 commit comments