Skip to content

Commit 7401da3

Browse files
committed
Switch python_files to be Iterable[str] as only used that way & restrict bandit to source files
1 parent 0afc3fb commit 7401da3

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

exasol/toolbox/nox/_artifacts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
from nox import Session
1111

1212
from exasol.toolbox.nox._shared import MINIMUM_PYTHON_VERSION
13-
from noxconfig import PROJECT_CONFIG, Config
13+
from noxconfig import (
14+
PROJECT_CONFIG,
15+
Config,
16+
)
1417

1518
COVERAGE_FILE = ".coverage"
1619
COVERAGE_XML = "ci-coverage.xml"
@@ -197,7 +200,7 @@ def _upload_to_sonar(session: Session, sonar_token: str, config: Config) -> None
197200
"--sonar-python-version",
198201
",".join(config.python_versions),
199202
"--sonar-sources",
200-
config.source
203+
config.source,
201204
]
202205
session.run(*command)
203206

exasol/toolbox/nox/_format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _pyupgrade(session: Session, config: Config, files: Iterable[str]) -> None:
3939
@nox.session(name="project:fix", python=False)
4040
def fix(session: Session) -> None:
4141
"""Runs all automated fixes on the code base"""
42-
py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)]
42+
py_files = python_files(PROJECT_CONFIG.root)
4343
_version(session, Mode.Fix)
4444
_pyupgrade(session, config=PROJECT_CONFIG, files=py_files)
4545
_code_format(session, Mode.Fix, py_files)
@@ -48,5 +48,5 @@ def fix(session: Session) -> None:
4848
@nox.session(name="project:format", python=False)
4949
def fmt_check(session: Session) -> None:
5050
"""Checks the project for correct formatting"""
51-
py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)]
51+
py_files = python_files(PROJECT_CONFIG.root)
5252
_code_format(session=session, mode=Mode.Check, files=py_files)

exasol/toolbox/nox/_lint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ def report_illegal(illegal: dict[str, list[str]], console: rich.console.Console)
118118

119119
@nox.session(name="lint:code", python=False)
120120
def lint(session: Session) -> None:
121-
"Runs the static code analyzer on the project"
122-
py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)]
121+
"""Runs the static code analyzer on the project"""
122+
py_files = python_files(PROJECT_CONFIG.root)
123123
_pylint(session, py_files)
124124

125125

@@ -133,7 +133,7 @@ def type_check(session: Session) -> None:
133133
@nox.session(name="lint:security", python=False)
134134
def security_lint(session: Session) -> None:
135135
"""Runs the security linter on the project"""
136-
py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)]
136+
py_files = python_files(PROJECT_CONFIG.root / PROJECT_CONFIG.source)
137137
_security_lint(session, py_files)
138138

139139

exasol/toolbox/nox/_shared.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ class Mode(Enum):
2828
Check = auto()
2929

3030

31-
def python_files(project_root: Path) -> Iterable[Path]:
31+
def python_files(project_root: Path) -> Iterable[str]:
3232
"""
3333
Returns iterable of python files after removing unwanted paths
3434
"""
3535
deny_list = DEFAULT_PATH_FILTERS.union(set(PROJECT_CONFIG.path_filters))
3636

3737
files = project_root.glob("**/*.py")
38-
return [path for path in files if not set(path.parts).intersection(deny_list)]
38+
return [f"{path}" for path in files if not set(path.parts).intersection(deny_list)]
3939

4040

4141
def _version(session: Session, mode: Mode) -> None:

exasol/toolbox/nox/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
def check(session: Session) -> None:
3434
"""Runs all available checks on the project"""
3535
context = _context(session, coverage=True)
36-
py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)]
36+
py_files = python_files(PROJECT_CONFIG.root)
3737
_version(session, Mode.Check)
3838
_code_format(session, Mode.Check, py_files)
3939
_pylint(session, py_files)

test/unit/nox/_shared_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ def test_python_files(
5151

5252
actual = python_files(tmp_directory)
5353
assert len(actual) == 1
54-
assert actual[0].parent.name == package_directory
54+
assert "toolbox-dummy" in actual[0]

0 commit comments

Comments
 (0)