Skip to content

Commit 16f766b

Browse files
authored
[python-jenkins] Improve get_jobs and get_all_jobs return type (#14547)
1 parent a922fc6 commit 16f766b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

stubs/python-jenkins/jenkins/__init__.pyi

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from _typeshed import Incomplete
22
from collections.abc import Mapping, MutableMapping, Sequence
33
from re import Pattern
4-
from typing import Any, Final, Literal, overload
5-
from typing_extensions import TypeAlias, deprecated
4+
from typing import Any, Final, Literal, TypedDict, overload, type_check_only
5+
from typing_extensions import Required, TypeAlias, deprecated
66

77
import requests
88
from requests.models import Request, Response
@@ -92,6 +92,15 @@ class WrappedSession(requests.Session):
9292
_JSONValue: TypeAlias = Any # too many possibilities to express
9393
_JSON: TypeAlias = dict[str, _JSONValue]
9494

95+
@type_check_only
96+
class _Job(TypedDict, total=False):
97+
_class: Required[str]
98+
url: Required[str]
99+
color: str
100+
name: Required[str]
101+
fullname: Required[str]
102+
jobs: list[_Job]
103+
95104
class Jenkins:
96105
server: str
97106
auth: _Auth | None
@@ -128,10 +137,8 @@ class Jenkins:
128137
def get_plugins_info(self, depth: int = 2) -> _JSON: ...
129138
def get_plugin_info(self, name: str, depth: int = 2) -> _JSON: ...
130139
def get_plugins(self, depth: int = 2) -> _JSON: ...
131-
def get_jobs(
132-
self, folder_depth: int = 0, folder_depth_per_request: int = 10, view_name: str | None = None
133-
) -> list[dict[str, str]]: ...
134-
def get_all_jobs(self, folder_depth: int | None = None, folder_depth_per_request: int = 10) -> list[dict[str, str]]: ...
140+
def get_jobs(self, folder_depth: int = 0, folder_depth_per_request: int = 10, view_name: str | None = None) -> list[_Job]: ...
141+
def get_all_jobs(self, folder_depth: int | None = None, folder_depth_per_request: int = 10) -> list[_Job]: ...
135142
def copy_job(self, from_name: str, to_name: str) -> None: ...
136143
def rename_job(self, from_name: str, to_name: str) -> None: ...
137144
def delete_job(self, name: str) -> None: ...

0 commit comments

Comments
 (0)