Skip to content

Commit 80fac75

Browse files
changed config file input
1 parent b66c23b commit 80fac75

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

exasol/toolbox/nox/_lint.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from __future__ import annotations
22

33
from typing import Iterable
4+
import argparse
5+
from pathlib import Path
46

57
import nox
68
from nox import Session
@@ -62,11 +64,34 @@ def type_check(session: Session) -> None:
6264

6365

6466
@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+
def import_lint(session: Session) -> None:
6768
"""Runs the import linter on the project"""
68-
if own_config_file == 'yes':
69-
path = input("Config file: ")
69+
70+
usage = "nox -s import-lint -- [options]"
71+
description = "Runs the import linter on the project"
72+
parser = argparse.ArgumentParser(
73+
description=description,
74+
usage=usage
75+
)
76+
parser.add_argument(
77+
"-c",
78+
"--config",
79+
type=str,
80+
help="path to the configuration file for the importlinter",
81+
metavar="TEXT"
82+
)
83+
84+
args: argparse.Namespace = parser.parse_args(args=session.posargs)
85+
file: str = args.config
86+
print(f"-{file}-")
87+
if file is None:
88+
path: path = getattr(PROJECT_CONFIG, "importlinter", Path(".importlinter"))
89+
else:
90+
path: path = Path(file)
91+
if path.exists():
92+
_import_lint(session=session, path=path)
7093
else:
71-
path = str(PROJECT_CONFIG.importlinter)
72-
_import_lint(session, path)
94+
session.error(
95+
"Please make sure you have a configuration file for the importlinter"
96+
)
97+

0 commit comments

Comments
 (0)