Skip to content

Commit 989e3d2

Browse files
committed
cursor(rules[dev-loop]) Sync with latest python loop
1 parent 3d32b46 commit 989e3d2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

.cursor/rules/dev-loop.mdc

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
description: QA every edit
33
globs: *.py
4+
alwaysApply: true
45
---
56

67
# Development Process
@@ -167,3 +168,20 @@ For doctests in `src/**/*.py` files:
167168
2. **Preferred pytest patterns**:
168169
- Use `tmp_path` (pathlib.Path) fixture over Python's `tempfile`
169170
- Use `monkeypatch` fixture over `unittest.mock`
171+
172+
### Import Guidelines
173+
174+
1. **Prefer namespace imports**:
175+
- Import modules and access attributes through the namespace instead of importing specific symbols
176+
- Example: Use `import enum` and access `enum.Enum` instead of `from enum import Enum`
177+
- This applies to standard library modules like `pathlib`, `os`, and similar cases
178+
179+
2. **Standard aliases**:
180+
- For `typing` module, use `import typing as t`
181+
- Access typing elements via the namespace: `t.NamedTuple`, `t.TypedDict`, etc.
182+
- Note primitive types like unions can be done via `|` pipes and primitive types like list and dict can be done via `list` and `dict` directly.
183+
184+
3. **Benefits of namespace imports**:
185+
- Improves code readability by making the source of symbols clear
186+
- Reduces potential naming conflicts
187+
- Makes import statements more maintainable

0 commit comments

Comments
 (0)