-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathno-relative-imports.mdc
More file actions
54 lines (44 loc) · 1.43 KB
/
no-relative-imports.mdc
File metadata and controls
54 lines (44 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# No Relative Imports
Standards for using absolute imports instead of relative imports in Python files.
<rule>
name: no_relative_imports
description: Enforce the use of absolute imports instead of relative imports in Python files
filters:
- type: file_extension
pattern: "\\.py$"
- type: content
pattern: "^from \\."
actions:
- type: reject
conditions:
- pattern: "^from \\."
message: "Use absolute imports (from stackone_ai...) instead of relative imports"
- type: suggest
message: |
When importing modules:
1. Always use absolute imports:
```python
# Good
from stackone_ai.models import ToolDefinition
from stackone_ai.constants import DEFAULT_HYBRID_ALPHA
# Bad
from .models import ToolDefinition
from ..constants import DEFAULT_HYBRID_ALPHA
```
2. Guidelines:
- Start imports with the full package name (stackone_ai)
- Never use relative imports (. or ..)
- Keep imports organized and grouped
examples:
- input: |
# Bad: Using relative imports
from .models import ToolDefinition
from ..constants import DEFAULT_HYBRID_ALPHA
# Good: Using absolute imports
from stackone_ai.models import ToolDefinition
from stackone_ai.constants import DEFAULT_HYBRID_ALPHA
output: "Correctly formatted absolute imports"
metadata:
priority: high
version: 1.0
</rule>