File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -168,3 +168,20 @@ For doctests in `src/**/*.py` files:
1681682. **Preferred pytest patterns**:
169169 - Use `tmp_path` (pathlib.Path) fixture over Python's `tempfile`
170170 - 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