Skip to content

Commit 3c985d7

Browse files
committed
[python-jenkins] Improve get_jobs and get_all_jobs return type
1 parent c3a880b commit 3c985d7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

stubs/python-jenkins/jenkins/__init__.pyi

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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
4+
from typing import Any, Final, Literal, TypedDict, overload, type_check_only
55
from typing_extensions import TypeAlias, deprecated
66

77
import requests
@@ -92,6 +92,14 @@ 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: str
98+
url: str
99+
color: str
100+
name: str
101+
jobs: list[_Job]
102+
95103
class Jenkins:
96104
server: str
97105
auth: _Auth | None
@@ -128,10 +136,8 @@ class Jenkins:
128136
def get_plugins_info(self, depth: int = 2) -> _JSON: ...
129137
def get_plugin_info(self, name: str, depth: int = 2) -> _JSON: ...
130138
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]]: ...
139+
def get_jobs(self, folder_depth: int = 0, folder_depth_per_request: int = 10, view_name: str | None = None) -> list[_Job]: ...
140+
def get_all_jobs(self, folder_depth: int | None = None, folder_depth_per_request: int = 10) -> list[_Job]: ...
135141
def copy_job(self, from_name: str, to_name: str) -> None: ...
136142
def rename_job(self, from_name: str, to_name: str) -> None: ...
137143
def delete_job(self, name: str) -> None: ...

0 commit comments

Comments
 (0)