44import re
55import subprocess
66import sys
7+ from collections .abc import (
8+ Generator ,
9+ Iterable ,
10+ )
711from dataclasses import (
812 asdict ,
913 dataclass ,
1216from functools import partial
1317from inspect import cleandoc
1418from pathlib import Path
15- from typing import (
16- Generator ,
17- Iterable ,
18- Tuple ,
19- )
19+ from typing import Tuple
2020
2121import 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
136136def 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
163162def 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]:
218217CVE_CLI = typer .Typer ()
219218CLI .add_typer (CVE_CLI , name = "cve" , help = "Work with CVE's" )
220219
220+
221221class Format (str , Enum ):
222222 Maven = "maven"
223223
@@ -321,8 +321,10 @@ class PPrintFormats(str, Enum):
321321
322322@CLI .command (name = "pretty-print" )
323323def 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