Skip to content

Commit 71efda1

Browse files
committed
Enable and configure banned imports
1 parent 145baf9 commit 71efda1

File tree

9 files changed

+74
-30
lines changed

9 files changed

+74
-30
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ select = [
146146
"I", # isort
147147
"N", # pep8-naming
148148
"S", # flake8-bandit
149+
"TID", # flake8-tidy-imports
149150
"RUF", # ruff-specific-rules
150151
]
151152
# Ignoring rules problematic with formatter

src/common/pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[tool.ruff]
2+
# Extend the `pyproject.toml` file in the parent directory...
3+
extend = "../../pyproject.toml"
4+
5+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
6+
"domains".msg = "Clean Architecture dependency rule break: import of `domains` is not allowed"
7+
"dramatiq_worker".msg = "Clean Architecture dependency rule break: import of `dramatiq_worker` is not allowed"
8+
"http_app".msg = "Clean Architecture dependency rule break: import of `http_app` is not allowed"
9+
"gateways".msg = "Clean Architecture dependency rule break: import of `gateways` is not allowed"
10+
"migrations".msg = "Clean Architecture dependency rule break: import of `migrations` is not allowed"
11+
"socketio_app".msg = "Clean Architecture dependency rule break: import of `socketio_app` is not allowed"
12+
13+
# These ignore rules suggest these modules should not be inside `common`.
14+
[tool.ruff.lint.per-file-ignores]
15+
"storage/**/*.py" = ["TID251"] # Storage is allowed to import domains module as it needs the models
16+
"di_container.py" = ["TID251"] # DI Container is allowed to import domains module

src/domains/pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[tool.ruff]
2+
# Extend the `pyproject.toml` file in the parent directory...
3+
extend = "../../pyproject.toml"
4+
5+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
6+
"dramatiq_worker".msg = "Clean Architecture dependency rule break: import of `dramatiq_worker` is not allowed"
7+
"http_app".msg = "Clean Architecture dependency rule break: import of `http_app` is not allowed"
8+
"gateways".msg = "Clean Architecture dependency rule break: import of `gateways` is not allowed"
9+
"migrations".msg = "Clean Architecture dependency rule break: import of `migrations` is not allowed"
10+
"socketio_app".msg = "Clean Architecture dependency rule break: import of `socketio_app` is not allowed"

src/dramatiq_worker/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.ruff]
2+
# Extend the `pyproject.toml` file in the parent directory...
3+
extend = "../../pyproject.toml"
4+
5+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
6+
"http_app".msg = "Clean Architecture dependency rule break: import of `http_app` is not allowed"
7+
"gateways".msg = "Clean Architecture dependency rule break: import of `gateways` is not allowed"
8+
"migrations".msg = "Clean Architecture dependency rule break: import of `migrations` is not allowed"
9+
"socketio_app".msg = "Clean Architecture dependency rule break: import of `socketio_app` is not allowed"

src/gateways/pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tool.ruff]
2+
# Extend the `pyproject.toml` file in the parent directory...
3+
extend = "../../pyproject.toml"
4+
5+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
6+
"domains".msg = "Clean Architecture dependency rule break: import of `domains` is not allowed"
7+
"dramatiq_worker".msg = "Clean Architecture dependency rule break: import of `dramatiq_worker` is not allowed"
8+
"http_app".msg = "Clean Architecture dependency rule break: import of `http_app` is not allowed"
9+
"gateways".msg = "Clean Architecture dependency rule break: import of `gateways` is not allowed"
10+
"migrations".msg = "Clean Architecture dependency rule break: import of `migrations` is not allowed"
11+
"socketio_app".msg = "Clean Architecture dependency rule break: import of `socketio_app` is not allowed"

src/http_app/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.ruff]
2+
# Extend the `pyproject.toml` file in the parent directory...
3+
extend = "../../pyproject.toml"
4+
5+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
6+
"dramatiq_worker".msg = "Clean Architecture dependency rule break: import of `dramatiq_worker` is not allowed"
7+
"gateways".msg = "Clean Architecture dependency rule break: import of `gateways` is not allowed"
8+
"migrations".msg = "Clean Architecture dependency rule break: import of `migrations` is not allowed"
9+
"socketio_app".msg = "Clean Architecture dependency rule break: import of `socketio_app` is not allowed"

src/migrations/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.ruff]
2+
# Extend the `pyproject.toml` file in the parent directory...
3+
extend = "../../pyproject.toml"
4+
5+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
6+
"dramatiq_worker".msg = "Clean Architecture dependency rule break: import of `dramatiq_worker` is not allowed"
7+
"http_app".msg = "Clean Architecture dependency rule break: import of `http_app` is not allowed"
8+
"gateways".msg = "Clean Architecture dependency rule break: import of `gateways` is not allowed"
9+
"socketio_app".msg = "Clean Architecture dependency rule break: import of `socketio_app` is not allowed"

src/socketio_app/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.ruff]
2+
# Extend the `pyproject.toml` file in the parent directory...
3+
extend = "../../pyproject.toml"
4+
5+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
6+
"dramatiq_worker".msg = "Clean Architecture dependency rule break: import of `dramatiq_worker` is not allowed"
7+
"http_app".msg = "Clean Architecture dependency rule break: import of `http_app` is not allowed"
8+
"gateways".msg = "Clean Architecture dependency rule break: import of `gateways` is not allowed"
9+
"migrations".msg = "Clean Architecture dependency rule break: import of `migrations` is not allowed"

test-cross-domain-imports.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)