Skip to content

Commit b66c23b

Browse files
add import linter to nox
1 parent 9d17e6f commit b66c23b

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.importlinter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[importlinter]
2+
root_package = exasol.toolbox

exasol/toolbox/nox/_lint.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ def _type_check(session: Session, files: Iterable[str]) -> None:
3737
)
3838

3939

40+
def _import_lint(session: Session, path: str) -> None:
41+
session.run(
42+
"poetry",
43+
"run",
44+
"lint-imports",
45+
"--config",
46+
path
47+
)
48+
49+
4050
@nox.session(python=False)
4151
def lint(session: Session) -> None:
4252
"""Runs the linter on the project"""
@@ -49,3 +59,14 @@ def type_check(session: Session) -> None:
4959
"""Runs the type checker on the project"""
5060
py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)]
5161
_type_check(session, py_files)
62+
63+
64+
@nox.session(name="import-lint", python=False)
65+
@nox.parametrize('own_config_file', ['no', 'yes'])
66+
def import_lint(session: Session, own_config_file: str) -> None:
67+
"""Runs the import linter on the project"""
68+
if own_config_file == 'yes':
69+
path = input("Config file: ")
70+
else:
71+
path = str(PROJECT_CONFIG.importlinter)
72+
_import_lint(session, path)

noxconfig.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Config:
3434

3535
root: Path = Path(__file__).parent
3636
doc: Path = Path(__file__).parent / "doc"
37+
importlinter: Path = Path(__file__).parent / ".importlinter"
3738
version_file: Path = Path(__file__).parent / "exasol" / "toolbox" / "version.py"
3839
path_filters: Iterable[str] = ("dist", ".eggs", "venv", "metrics-schema", "project-template")
3940
plugins = [UpdateTemplates]

pyproject.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,3 @@ ignore_errors = true
110110
[tool.poetry.scripts]
111111
tbx = 'exasol.toolbox.tools.tbx:CLI'
112112

113-
[tool.importlinter]
114-
root_package = "exasol.toolbox"
115-
include_external_packages = true
116-
117-
[[tool.importlinter.contracts]]
118-
name = "contract test"
119-
type = "independence"

0 commit comments

Comments
 (0)