File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
description: QA every edit
3
3
globs: *.py
4
+ alwaysApply: true
4
5
---
5
6
6
7
# Development Process
@@ -167,3 +168,20 @@ For doctests in `src/**/*.py` files:
167
168
2. **Preferred pytest patterns**:
168
169
- Use `tmp_path` (pathlib.Path) fixture over Python's `tempfile`
169
170
- 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
You can’t perform that action at this time.
0 commit comments