Skip to content

Commit c7b5624

Browse files
committed
chore(python): 3.12 style
1 parent 2f08410 commit c7b5624

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ga_actions_check_ref.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import re
55
import sys
66
from dataclasses import dataclass, field
7-
from typing import IO, Dict, Hashable, List, Mapping
7+
from typing import IO
8+
from collections.abc import Hashable, Mapping
89

910
import yaml
1011
from jsonpath_ng import parse
@@ -15,7 +16,7 @@
1516
class SafeLineLoader(SafeLoader):
1617
def construct_mapping(
1718
self, node: MappingNode, deep: bool = False
18-
) -> Dict[Hashable, None]:
19+
) -> dict[Hashable, None]:
1920
mapping = super().construct_mapping(node, deep=deep)
2021
# Add 1 so line numbering starts at 1
2122
mapping["line"] = node.start_mark.line + 1
@@ -42,7 +43,7 @@ def __post_init__(self) -> None:
4243
self.name = f"{self.owner}/{self.repository}"
4344

4445

45-
def find_gitub_actions_in_workflow(file: IO) -> List[GithubActions]:
46+
def find_gitub_actions_in_workflow(file: IO) -> list[GithubActions]:
4647
github_actions = []
4748
jsonpath_expr = parse("jobs.*.steps[*].uses")
4849
file = yaml.load(file, Loader=SafeLineLoader) # nosec
@@ -96,7 +97,6 @@ def is_github_workflow_valid(file: IO, allowed_actions: Mapping[str, str]) -> bo
9697
def load_allowed_actions() -> Mapping[str, str]:
9798
with open(
9899
f"{os.environ['GITHUB_ACTION_PATH']}/ALLOWED_ACTIONS.yaml",
99-
mode="r",
100100
encoding="utf-8",
101101
) as file:
102102
return yaml.safe_load(file)
@@ -107,7 +107,7 @@ def main() -> None:
107107
allowed_actions = load_allowed_actions()
108108
for extension in ("yaml", "yml"):
109109
for entry in glob.glob(f".github/workflows/**/*.{extension}", recursive=True):
110-
with open(entry, mode="r", encoding="utf-8") as file:
110+
with open(entry, encoding="utf-8") as file:
111111
executions.append(is_github_workflow_valid(file, allowed_actions))
112112

113113
sys.exit(not all(executions))

tests/test_list_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
def test_list_valid_github_actions() -> None:
5-
with open("tests/sample_workflow.yaml", mode="r", encoding="utf-8") as file:
5+
with open("tests/sample_workflow.yaml", encoding="utf-8") as file:
66
assert [
77
github_actions.name
88
for github_actions in find_gitub_actions_in_workflow(file)

0 commit comments

Comments
 (0)