Skip to content

Commit 22bc3da

Browse files
committed
Switch Union[*, None] with Optional[*]
1 parent d5069c4 commit 22bc3da

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

exasol/toolbox/nox/_artifacts.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import sys
88
from collections.abc import Iterable
99
from pathlib import Path
10-
from typing import (
11-
Optional,
12-
Union,
13-
)
10+
from typing import Optional
1411

1512
import nox
1613
from nox import Session
@@ -188,7 +185,7 @@ def _copy_artifacts(source: Path, dest: Path, files: Iterable[str]):
188185

189186

190187
def _prepare_coverage_xml(
191-
session: Session, source: Path, cwd: Union[Path, None] = None
188+
session: Session, source: Path, cwd: Optional[Path] = None
192189
) -> None:
193190
"""
194191
Prepare the coverage XML for input into Sonar

exasol/toolbox/util/dependencies/track_changes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import (
4-
Union,
5-
)
3+
from typing import Optional
64

75
from packaging.version import Version
86
from pydantic import (
@@ -73,7 +71,7 @@ class DependencyChanges(BaseModel):
7371

7472
def _categorize_change(
7573
self, dependency_name: NormalizedPackageStr
76-
) -> Union[DependencyChange, None]:
74+
) -> Optional[DependencyChange]:
7775
"""
7876
Categorize dependency change as removed, added, or updated.
7977
"""
@@ -84,7 +82,9 @@ def _categorize_change(
8482
elif not previous_dependency and current_dependency:
8583
return AddedDependency.from_package(current_dependency)
8684
elif previous_dependency.version != current_dependency.version: # type: ignore
87-
return UpdatedDependency.from_package(previous_dependency, current_dependency) # type: ignore
85+
return UpdatedDependency.from_package(
86+
previous_dependency, current_dependency
87+
) # type: ignore
8888
# dependency was unchanged between versions
8989
return None
9090

test/integration/project-template/nox_test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Union
1+
from typing import Optional
22

33

44
class TestSpecificNoxTasks:
@@ -14,8 +14,10 @@ class TestSpecificNoxTasks:
1414
both the relationships between nox tasks and ensuring that the project-template
1515
passes CI tests when a new project is created from it.
1616
"""
17+
1718
@staticmethod
18-
def _command(poetry_path: str, task: str, add_ons: Union[list[str], None]=None) -> list[str]:
19+
def _command(poetry_path: str, task: str,
20+
add_ons: Optional[list[str]] = None) -> list[str]:
1921
base = [poetry_path, "run", "--", "nox", "-s", task]
2022
if add_ons:
2123
base = base + ["--"] + add_ons
@@ -33,9 +35,10 @@ def test_artifact_validate(self, poetry_path, run_command):
3335
run_command(lint_code)
3436
lint_security = self._command(poetry_path, "lint:security")
3537
run_command(lint_security)
36-
test_unit = self._command(poetry_path, "test:unit",["--coverage"])
38+
test_unit = self._command(poetry_path, "test:unit", ["--coverage"])
3739
run_command(test_unit)
38-
test_integration = self._command(poetry_path, "test:integration",["--coverage"])
40+
test_integration = self._command(poetry_path, "test:integration",
41+
["--coverage"])
3942
run_command(test_integration)
4043
# `artifacts:copy` is skipped here. This step has the pre-requisite that files
4144
# were uploaded to & then downloaded from the GitHub run's artifacts.

test/unit/util/dependencies/licenses_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Union
1+
from typing import Optional
22

33
import pytest
44

@@ -167,8 +167,8 @@ def test_format_group_table(package_license_report, dependencies, main_group):
167167
)
168168
def test_format_table_row(
169169
package_license_report,
170-
package_link: Union[str, None],
171-
license_link: Union[str, None],
170+
package_link: Optional[str],
171+
license_link: Optional[str],
172172
expected,
173173
):
174174
_license = PackageLicense(

0 commit comments

Comments
 (0)