ci/bin: Fix mypy errors in gitlab_gql.py
Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25940>
This commit is contained in:

committed by
Marge Bot

parent
b87e092489
commit
e74238af42
@@ -36,9 +36,9 @@ TOKEN_DIR = Path(getenv("XDG_CONFIG_HOME") or Path.home() / ".config")
|
|||||||
|
|
||||||
|
|
||||||
def get_token_from_default_dir() -> str:
|
def get_token_from_default_dir() -> str:
|
||||||
|
token_file = TOKEN_DIR / "gitlab-token"
|
||||||
try:
|
try:
|
||||||
token_file = TOKEN_DIR / "gitlab-token"
|
return str(token_file.resolve())
|
||||||
return token_file.resolve()
|
|
||||||
except FileNotFoundError as ex:
|
except FileNotFoundError as ex:
|
||||||
print(
|
print(
|
||||||
f"Could not find {token_file}, please provide a token file as an argument"
|
f"Could not find {token_file}, please provide a token file as an argument"
|
||||||
@@ -61,10 +61,10 @@ class GitlabGQL:
|
|||||||
url: str = "https://gitlab.freedesktop.org/api/graphql"
|
url: str = "https://gitlab.freedesktop.org/api/graphql"
|
||||||
token: Optional[str] = None
|
token: Optional[str] = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self) -> None:
|
||||||
self._setup_gitlab_gql_client()
|
self._setup_gitlab_gql_client()
|
||||||
|
|
||||||
def _setup_gitlab_gql_client(self) -> Client:
|
def _setup_gitlab_gql_client(self) -> None:
|
||||||
# Select your transport with a defined url endpoint
|
# Select your transport with a defined url endpoint
|
||||||
headers = {}
|
headers = {}
|
||||||
if self.token:
|
if self.token:
|
||||||
@@ -117,8 +117,8 @@ class GitlabGQL:
|
|||||||
operation_name: Optional[str] = None,
|
operation_name: Optional[str] = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
# Provide a GraphQL query
|
# Provide a GraphQL query
|
||||||
source_path = Path(__file__).parent
|
source_path: Path = Path(__file__).parent
|
||||||
pipeline_query_file = source_path / gql_file
|
pipeline_query_file: Path = source_path / gql_file
|
||||||
|
|
||||||
query: DocumentNode
|
query: DocumentNode
|
||||||
with open(pipeline_query_file, "r") as f:
|
with open(pipeline_query_file, "r") as f:
|
||||||
@@ -347,7 +347,7 @@ def print_dag(dag: Dag) -> None:
|
|||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
def fetch_merged_yaml(gl_gql: GitlabGQL, params) -> dict[Any]:
|
def fetch_merged_yaml(gl_gql: GitlabGQL, params) -> dict[str, Any]:
|
||||||
gitlab_yml_file = get_project_root_dir() / ".gitlab-ci.yml"
|
gitlab_yml_file = get_project_root_dir() / ".gitlab-ci.yml"
|
||||||
content = Path(gitlab_yml_file).read_text().strip()
|
content = Path(gitlab_yml_file).read_text().strip()
|
||||||
params["content"] = content
|
params["content"] = content
|
||||||
@@ -371,7 +371,7 @@ def recursive_fill(job, relationship_field, target_data, acc_data: dict, merged_
|
|||||||
|
|
||||||
for relative in relatives:
|
for relative in relatives:
|
||||||
parent_job = merged_yaml[relative]
|
parent_job = merged_yaml[relative]
|
||||||
acc_data = recursive_fill(parent_job, acc_data, merged_yaml)
|
acc_data = recursive_fill(parent_job, acc_data, merged_yaml) # type: ignore
|
||||||
|
|
||||||
acc_data |= job.get(target_data, {})
|
acc_data |= job.get(target_data, {})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user