Skip to content

Commit 2ec899f

Browse files
committed
Run project:fix on files with pyupgrade change
1 parent b63596e commit 2ec899f

File tree

12 files changed

+33
-37
lines changed

12 files changed

+33
-37
lines changed

exasol/toolbox/metrics.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import subprocess
55
import sys
66
from collections import defaultdict
7+
from collections.abc import Callable
78
from dataclasses import (
89
asdict,
910
dataclass,
@@ -18,7 +19,6 @@
1819
from tempfile import TemporaryDirectory
1920
from 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

161161
def 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

199199
def 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:

exasol/toolbox/nox/_artifacts.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _copy_artifacts(source: Path, dest: Path, files: Iterable[str]):
185185

186186

187187
def _prepare_coverage_xml(
188-
session: Session, source: Path, cwd: Optional[Path] = None
188+
session: Session, source: Path, cwd: Path | None = None
189189
) -> None:
190190
"""
191191
Prepare the coverage XML for input into Sonar
@@ -225,9 +225,7 @@ def _prepare_coverage_xml(
225225
session.error(output.returncode, output.stdout, output.stderr)
226226

227227

228-
def _upload_to_sonar(
229-
session: Session, sonar_token: Optional[str], config: Config
230-
) -> None:
228+
def _upload_to_sonar(session: Session, sonar_token: str | None, config: Config) -> None:
231229
command = [
232230
"pysonar",
233231
"--sonar-token",

exasol/toolbox/tools/replace_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import re
2+
from collections.abc import Callable
23
from dataclasses import dataclass
34
from enum import Enum
45
from pathlib import Path
56
from typing import (
6-
Callable,
77
Optional,
88
)
99

@@ -54,7 +54,7 @@ def __init__(
5454
self.pattern = pattern
5555
self.version_string_modifier = version_string_modifier
5656

57-
def replace_version(self, line: str, version: Version) -> Optional[str]:
57+
def replace_version(self, line: str, version: Version) -> str | None:
5858
match = re.search(self.pattern.full_pattern, line)
5959
if match:
6060
return self.pattern.replace_version(

exasol/toolbox/tools/security.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ def as_markdown_listing(elements: Iterable[str]):
276276
)
277277

278278

279-
def create_security_issue(
280-
issue: Issue, project: Optional[str] = None
281-
) -> tuple[str, str]:
279+
def create_security_issue(issue: Issue, project: str | None = None) -> tuple[str, str]:
282280
# fmt: off
283281
command = [
284282
"gh", "issue", "create",

exasol/toolbox/tools/template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def diff_template(template: str, dest: Path, pkg: str, template_type: str) -> No
8686

8787
def _install_template(
8888
template_type: str,
89-
src: Union[str, Path],
90-
dest: Union[str, Path],
89+
src: str | Path,
90+
dest: str | Path,
9191
exists_ok: bool = False,
9292
) -> None:
9393
src, dest = Path(src), Path(dest)

exasol/toolbox/util/dependencies/audit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def from_audit_entry(
5555
)
5656

5757
@property
58-
def security_issue_entry(self) -> dict[str, Union[str, list[str]]]:
58+
def security_issue_entry(self) -> dict[str, str | list[str]]:
5959
return {
6060
"name": self.name,
6161
"version": str(self.version),
@@ -141,7 +141,7 @@ def load_from_pip_audit(cls, working_directory: Path) -> Vulnerabilities:
141141
return Vulnerabilities(vulnerabilities=vulnerabilities)
142142

143143
@property
144-
def security_issue_dict(self) -> list[dict[str, Union[str, list[str]]]]:
144+
def security_issue_dict(self) -> list[dict[str, str | list[str]]]:
145145
return [
146146
vulnerability.security_issue_entry for vulnerability in self.vulnerabilities
147147
]

exasol/toolbox/util/dependencies/licenses.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@
4141

4242

4343
class PackageLicense(Package):
44-
package_link: Optional[str]
44+
package_link: str | None
4545
license: str
4646

4747
@field_validator("package_link", mode="before")
48-
def map_unknown_to_none(cls, v) -> Optional[str]:
48+
def map_unknown_to_none(cls, v) -> str | None:
4949
if v == "UNKNOWN":
5050
return None
5151
return v
5252

5353
@field_validator("license", mode="before")
54-
def map_to_normalized_values(cls, v) -> Optional[str]:
54+
def map_to_normalized_values(cls, v) -> str | None:
5555
return _normalize(v)
5656

5757
@property
58-
def license_link(self) -> Optional[str]:
58+
def license_link(self) -> str | None:
5959
return LICENSE_MAPPING_TO_URL.get(self.license, None)
6060

6161

exasol/toolbox/util/dependencies/poetry_dependencies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class PoetryGroup(BaseModel):
2525
model_config = ConfigDict(frozen=True)
2626

2727
name: str
28-
toml_section: Optional[str]
28+
toml_section: str | None
2929

3030

3131
PYPROJECT_TOML = "pyproject.toml"
@@ -50,7 +50,7 @@ def load_from_toml(cls, working_directory: Path) -> PoetryToml:
5050
except Exception as e:
5151
raise ValueError(f"Error reading file: {str(e)}")
5252

53-
def get_section_dict(self, section: str) -> Optional[dict]:
53+
def get_section_dict(self, section: str) -> dict | None:
5454
current = self.content.copy()
5555
for section in section.split("."):
5656
if section not in current:
@@ -94,7 +94,7 @@ class PoetryDependencies(BaseModel):
9494
working_directory: Path
9595

9696
@staticmethod
97-
def _extract_from_line(line: str) -> Optional[Package]:
97+
def _extract_from_line(line: str) -> Package | None:
9898
# remove (!) from line as indicates not installed in environment,
9999
# which could occur for optional dependencies
100100
split_line = line.replace("(!)", "").strip().split(maxsplit=2)

exasol/toolbox/util/dependencies/track_changes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class DependencyChanges(BaseModel):
7171

7272
def _categorize_change(
7373
self, dependency_name: NormalizedPackageStr
74-
) -> Optional[DependencyChange]:
74+
) -> DependencyChange | None:
7575
"""
7676
Categorize dependency change as removed, added, or updated.
7777
"""

exasol/toolbox/util/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_latest_tag():
2727

2828
@staticmethod
2929
@run_command
30-
def read_file_from_tag(tag: str, path: Union[Path, str]):
30+
def read_file_from_tag(tag: str, path: Path | str):
3131
"""
3232
Read the contents of the specified file `path` at the point in
3333
time specified by git tag `tag`.

0 commit comments

Comments
 (0)