Skip to content

Commit 8e61e2e

Browse files
committed
add tool and update config and convention docs
1 parent 9245181 commit 8e61e2e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

docs/Coding-Conventions.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -802,14 +802,16 @@ from collections import defaultdict
802802
from contextlib import contextmanager
803803
```
804804

805-
### [O.1.5] ✔️ **DO** Use absolute imports
805+
### [O.1.5] ✔️ **DO** Use absolute imports 💻
806806

807807
> 🐍 This rule stems from [PEP 8](https://www.python.org/dev/peps/pep-0008)
808808
809+
> 💻 This rule is enforced by error code I252
810+
809811
ℹ️ An exception can be made for `__init__.py` files republishing child module declarations
810812

811813
```python
812-
# Bad
814+
# Bad - will produce I252
813815
from . import sibling
814816
from .sibling import rivalry
815817
```
@@ -869,8 +871,8 @@ import os # Assuming os is never used
869871
```
870872

871873
```python
872-
# Good - assuming we are in a __init__.py file
873-
from .mysubmodule import spam, eggs # OK even if neither are used in this module
874+
# Good - assuming we are in a monty/__init__.py file
875+
from monty.mysubmodule import spam, eggs # OK even if neither are used in this module
874876
```
875877

876878

ni_python_styleguide/config.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,5 @@ docstring-convention=all
129129

130130
# flake8-import-order
131131
import-order-style=smarkets
132+
133+
ban-relative-imports = True

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ isort = ">=5.10"
3838
flake8-black = ">=0.2.1"
3939
flake8-docstrings = ">=1.5.0"
4040
flake8-import-order = ">=0.18.1"
41+
flake8-tidy-imports = [
42+
{version = ">=4.4.1", python = ">=3.7,<3.9"},
43+
{version=">=4.11.0", python="^3.9"},
44+
]
4145
pep8-naming = ">=0.11.1"
4246

4347
# Rejected flake8 plugins should be listed here (in alphabetical order)

0 commit comments

Comments
 (0)