Skip to content

Commit dceb5d5

Browse files
resolve conversation
1 parent ce440fc commit dceb5d5

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

exasol/toolbox/nox/_lint.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import argparse
44
import sys
5+
from collections.abc import Iterable
56
from pathlib import Path
67
from typing import (
78
Dict,
8-
Iterable,
99
List,
10-
Dict
1110
)
1211

1312
import nox
@@ -18,11 +17,6 @@
1817
from exasol.toolbox.nox._shared import python_files
1918
from noxconfig import PROJECT_CONFIG
2019

21-
from pathlib import Path
22-
import rich.console
23-
import tomlkit
24-
import sys
25-
2620

2721
def _pylint(session: Session, files: Iterable[str]) -> None:
2822
session.run(
@@ -85,26 +79,23 @@ def _import_lint(session: Session, path: Path) -> None:
8579

8680

8781
class Dependencies:
88-
def __init__(self, illegal: Dict[str, List[str]] | None):
82+
def __init__(self, illegal: dict[str, list[str]] | None):
8983
self._illegal = illegal or {}
9084

9185
@staticmethod
92-
def parse(pyproject_toml: str) -> "Dependencies":
86+
def parse(pyproject_toml: str) -> Dependencies:
9387
def _source_filter(version) -> bool:
94-
ILLEGAL_SPECIFIERS = ['url', 'git', 'path']
95-
return any(
96-
specifier in version
97-
for specifier in ILLEGAL_SPECIFIERS
98-
)
88+
ILLEGAL_SPECIFIERS = ["url", "git", "path"]
89+
return any(specifier in version for specifier in ILLEGAL_SPECIFIERS)
9990

100-
def find_illegal(part) -> List[str]:
91+
def find_illegal(part) -> list[str]:
10192
return [
10293
f"{name} = {version}"
10394
for name, version in part.items()
10495
if _source_filter(version)
10596
]
10697

107-
illegal: Dict[str, List[str]] = {}
98+
illegal: dict[str, list[str]] = {}
10899
toml = tomlkit.loads(pyproject_toml)
109100
poetry = toml.get("tool", {}).get("poetry", {})
110101

@@ -124,11 +115,11 @@ def find_illegal(part) -> List[str]:
124115
return Dependencies(illegal)
125116

126117
@property
127-
def illegal(self) -> Dict[str, List[str]]:
118+
def illegal(self) -> dict[str, list[str]]:
128119
return self._illegal
129120

130121

131-
def report_illegal(illegal: Dict[str, List[str]], console: rich.console.Console):
122+
def report_illegal(illegal: dict[str, list[str]], console: rich.console.Console):
132123
count = sum(len(deps) for deps in illegal.values())
133124
suffix = "y" if count == 1 else "ies"
134125
console.print(f"{count} illegal dependenc{suffix}\n", style="red")
@@ -168,4 +159,4 @@ def dependency_check(session: Session) -> None:
168159
console = rich.console.Console()
169160
if illegal := dependencies.illegal:
170161
report_illegal(illegal, console)
171-
sys.exit(1)
162+
sys.exit(1)

exasol/toolbox/tools/security.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import re
55
import subprocess
66
import sys
7+
from collections.abc import (
8+
Generator,
9+
Iterable,
10+
)
711
from dataclasses import (
812
asdict,
913
dataclass,
@@ -12,11 +16,7 @@
1216
from functools import partial
1317
from inspect import cleandoc
1418
from pathlib import Path
15-
from typing import (
16-
Generator,
17-
Iterable,
18-
Tuple,
19-
)
19+
from typing import Tuple
2020

2121
import typer
2222

@@ -48,7 +48,7 @@ def _issues_as_json_str(issues):
4848
yield json.dumps(issue)
4949

5050

51-
def gh_security_issues() -> Generator[Tuple[str, str], None, None]:
51+
def gh_security_issues() -> Generator[tuple[str, str], None, None]:
5252
"""
5353
Yields issue-id, cve-id pairs for all (closed, open) issues associated with CVEs
5454
@@ -129,14 +129,16 @@ def from_json(report_str: str, prefix: Path) -> Iterable[SecurityIssue]:
129129
cwe=str(issue["issue_cwe"].get("id", "")),
130130
test_id=issue["test_id"],
131131
description=issue["issue_text"],
132-
references=tuple(references)
132+
references=tuple(references),
133133
)
134134

135135

136136
def issues_to_markdown(issues: Iterable[SecurityIssue]) -> str:
137-
template = cleandoc("""
137+
template = cleandoc(
138+
"""
138139
{header}{rows}
139-
""")
140+
"""
141+
)
140142

141143
def _header():
142144
header = "# Security\n\n"
@@ -154,10 +156,7 @@ def _row(issue):
154156
row = row[:-5] + "|"
155157
return row
156158

157-
return template.format(
158-
header=_header(),
159-
rows="\n".join(_row(i) for i in issues)
160-
)
159+
return template.format(header=_header(), rows="\n".join(_row(i) for i in issues))
161160

162161

163162
def security_issue_title(issue: Issue) -> str:
@@ -188,7 +187,7 @@ def as_markdown_listing(elements: Iterable[str]):
188187
)
189188

190189

191-
def create_security_issue(issue: Issue, project="") -> Tuple[str, str]:
190+
def create_security_issue(issue: Issue, project="") -> tuple[str, str]:
192191
# fmt: off
193192
command = [
194193
"gh", "issue", "create",
@@ -218,6 +217,7 @@ def create_security_issue(issue: Issue, project="") -> Tuple[str, str]:
218217
CVE_CLI = typer.Typer()
219218
CLI.add_typer(CVE_CLI, name="cve", help="Work with CVE's")
220219

220+
221221
class Format(str, Enum):
222222
Maven = "maven"
223223

@@ -321,8 +321,10 @@ class PPrintFormats(str, Enum):
321321

322322
@CLI.command(name="pretty-print")
323323
def json_issue_to_markdown(
324-
json_file: typer.FileText = typer.Argument(mode="r", help="json file with issues to convert"),
325-
path: Path = typer.Argument(default=Path("."), help="path to project root")
324+
json_file: typer.FileText = typer.Argument(
325+
mode="r", help="json file with issues to convert"
326+
),
327+
path: Path = typer.Argument(default=Path("."), help="path to project root"),
326328
) -> None:
327329
content = json_file.read()
328330
issues = from_json(content, path.absolute())

0 commit comments

Comments
 (0)