[python-jenkins] Improve get_jobs and get_all_jobs return type (#14547)

This commit is contained in:
Roberto Fernández Iglesias
2025-10-27 02:04:27 +01:00
committed by GitHub
parent a922fc6d1a
commit 16f766b754
+13 -6
View File
@@ -1,8 +1,8 @@
from _typeshed import Incomplete
from collections.abc import Mapping, MutableMapping, Sequence
from re import Pattern
from typing import Any, Final, Literal, overload
from typing_extensions import TypeAlias, deprecated
from typing import Any, Final, Literal, TypedDict, overload, type_check_only
from typing_extensions import Required, TypeAlias, deprecated
import requests
from requests.models import Request, Response
@@ -92,6 +92,15 @@ class WrappedSession(requests.Session):
_JSONValue: TypeAlias = Any # too many possibilities to express
_JSON: TypeAlias = dict[str, _JSONValue]
@type_check_only
class _Job(TypedDict, total=False):
_class: Required[str]
url: Required[str]
color: str
name: Required[str]
fullname: Required[str]
jobs: list[_Job]
class Jenkins:
server: str
auth: _Auth | None
@@ -128,10 +137,8 @@ class Jenkins:
def get_plugins_info(self, depth: int = 2) -> _JSON: ...
def get_plugin_info(self, name: str, depth: int = 2) -> _JSON: ...
def get_plugins(self, depth: int = 2) -> _JSON: ...
def get_jobs(
self, folder_depth: int = 0, folder_depth_per_request: int = 10, view_name: str | None = None
) -> list[dict[str, str]]: ...
def get_all_jobs(self, folder_depth: int | None = None, folder_depth_per_request: int = 10) -> list[dict[str, str]]: ...
def get_jobs(self, folder_depth: int = 0, folder_depth_per_request: int = 10, view_name: str | None = None) -> list[_Job]: ...
def get_all_jobs(self, folder_depth: int | None = None, folder_depth_per_request: int = 10) -> list[_Job]: ...
def copy_job(self, from_name: str, to_name: str) -> None: ...
def rename_job(self, from_name: str, to_name: str) -> None: ...
def delete_job(self, name: str) -> None: ...