44import subprocess
55import sys
66from collections import defaultdict
7+ from collections .abc import Callable
78from dataclasses import (
89 asdict ,
910 dataclass ,
1819from tempfile import TemporaryDirectory
1920from typing import (
2021 Any ,
21- Callable ,
2222 Dict ,
2323 List ,
2424 Optional ,
@@ -101,7 +101,7 @@ class Report:
101101 technical_debt : Rating
102102
103103
104- def total_coverage (file : Union [ str , Path ] ) -> float :
104+ def total_coverage (file : str | Path ) -> float :
105105 with TemporaryDirectory () as tmpdir :
106106 tmp_dir = Path (tmpdir )
107107 report = tmp_dir / "coverage.json"
@@ -133,8 +133,8 @@ def total_coverage(file: Union[str, Path]) -> float:
133133 return total
134134
135135
136- def _static_code_analysis (file : Union [ str , Path ] ) -> Rating :
137- def pylint (f : Union [ str , Path ] ) -> Rating :
136+ def _static_code_analysis (file : str | Path ) -> Rating :
137+ def pylint (f : str | Path ) -> Rating :
138138 expr = re .compile (r"^Your code has been rated at (\d+.\d+)/.*" , re .MULTILINE )
139139 with open (f , encoding = "utf-8" ) as results :
140140 data = results .read ()
@@ -154,15 +154,15 @@ def pylint(f: Union[str, Path]) -> Rating:
154154 return pylint_score
155155
156156
157- def maintainability (file : Union [ str , Path ] ) -> Rating :
157+ def maintainability (file : str | Path ) -> Rating :
158158 return _static_code_analysis (file )
159159
160160
161161def reliability () -> Rating :
162162 return Rating .NotAvailable
163163
164164
165- def security (file : Union [ str , Path ] ) -> Rating :
165+ def security (file : str | Path ) -> Rating :
166166 with open (file ) as json_file :
167167 security_lint = json .load (json_file )
168168 return Rating .bandit_rating (_bandit_scoring (security_lint ["results" ]))
@@ -198,10 +198,10 @@ def technical_debt() -> Rating:
198198
199199def create_report (
200200 commit : str ,
201- date : Optional [ datetime .datetime ] = None ,
202- coverage_report : Union [ str , Path ] = ".coverage" ,
203- pylint_report : Union [ str , Path ] = ".lint.txt" ,
204- bandit_report : Union [ str , Path ] = ".security.json" ,
201+ date : datetime .datetime | None = None ,
202+ coverage_report : str | Path = ".coverage" ,
203+ pylint_report : str | Path = ".lint.txt" ,
204+ bandit_report : str | Path = ".security.json" ,
205205) -> Report :
206206 return Report (
207207 commit = commit ,
@@ -254,7 +254,7 @@ def _rating_color(value: Rating) -> str:
254254
255255@color .register (float )
256256@color .register (int )
257- def _coverage_color (value : Union [ float , int ] ) -> str :
257+ def _coverage_color (value : float | int ) -> str :
258258 if 0 <= value < 20 :
259259 return _rating_color (Rating .F )
260260 elif 20 <= value < 50 :
0 commit comments