feat(api)!: ListMixin.list typing overload · python-gitlab/python-gitlab@6eee494

@@ -108,8 +108,25 @@ class SnippetManager(CRUDMixin[Snippet]):

108108

optional=("title", "files", "file_name", "content", "visibility", "description")

109109

)

110110111+

@overload

112+

def list_public(

113+

self, *, iterator: Literal[False] = False, **kwargs: Any

114+

) -> list[Snippet]: ...

115+116+

@overload

117+

def list_public(

118+

self, *, iterator: Literal[True] = True, **kwargs: Any

119+

) -> RESTObjectList[Snippet]: ...

120+121+

@overload

122+

def list_public(

123+

self, *, iterator: bool = False, **kwargs: Any

124+

) -> RESTObjectList[Snippet] | list[Snippet]: ...

125+111126

@cli.register_custom_action(cls_names="SnippetManager")

112-

def list_public(self, **kwargs: Any) -> RESTObjectList[Snippet] | list[Snippet]:

127+

def list_public(

128+

self, *, iterator: bool = False, **kwargs: Any

129+

) -> RESTObjectList[Snippet] | list[Snippet]:

113130

"""List all public snippets.

114131115132

Args:

@@ -126,10 +143,27 @@ def list_public(self, **kwargs: Any) -> RESTObjectList[Snippet] | list[Snippet]:

126143

Returns:

127144

The list of snippets, or a generator if `iterator` is True

128145

"""

129-

return self.list(path="/snippets/public", **kwargs)

146+

return self.list(path="/snippets/public", iterator=iterator, **kwargs)

147+148+

@overload

149+

def list_all(

150+

self, *, iterator: Literal[False] = False, **kwargs: Any

151+

) -> list[Snippet]: ...

152+153+

@overload

154+

def list_all(

155+

self, *, iterator: Literal[True] = True, **kwargs: Any

156+

) -> RESTObjectList[Snippet]: ...

157+158+

@overload

159+

def list_all(

160+

self, *, iterator: bool = False, **kwargs: Any

161+

) -> RESTObjectList[Snippet] | list[Snippet]: ...

130162131163

@cli.register_custom_action(cls_names="SnippetManager")

132-

def list_all(self, **kwargs: Any) -> RESTObjectList[Snippet] | list[Snippet]:

164+

def list_all(

165+

self, *, iterator: bool = False, **kwargs: Any

166+

) -> RESTObjectList[Snippet] | list[Snippet]:

133167

"""List all snippets.

134168135169

Args:

@@ -146,9 +180,30 @@ def list_all(self, **kwargs: Any) -> RESTObjectList[Snippet] | list[Snippet]:

146180

Returns:

147181

A generator for the snippets list

148182

"""

149-

return self.list(path="/snippets/all", **kwargs)

183+

return self.list(path="/snippets/all", iterator=iterator, **kwargs)

184+185+

@overload

186+

def public(

187+

self,

188+

*,

189+

iterator: Literal[False] = False,

190+

page: int | None = None,

191+

**kwargs: Any,

192+

) -> list[Snippet]: ...

193+194+

@overload

195+

def public(

196+

self, *, iterator: Literal[True] = True, **kwargs: Any

197+

) -> RESTObjectList[Snippet]: ...

198+199+

@overload

200+

def public(

201+

self, *, iterator: bool = False, **kwargs: Any

202+

) -> RESTObjectList[Snippet] | list[Snippet]: ...

150203151-

def public(self, **kwargs: Any) -> RESTObjectList[Snippet] | list[Snippet]:

204+

def public(

205+

self, *, iterator: bool = False, **kwargs: Any

206+

) -> RESTObjectList[Snippet] | list[Snippet]:

152207

"""List all public snippets.

153208154209

Args:

@@ -172,7 +227,7 @@ def public(self, **kwargs: Any) -> RESTObjectList[Snippet] | list[Snippet]:

172227

),

173228

category=DeprecationWarning,

174229

)

175-

return self.list(path="/snippets/public", **kwargs)

230+

return self.list(path="/snippets/public", iterator=iterator, **kwargs)

176231177232178233

class ProjectSnippet(UserAgentDetailMixin, SaveMixin, ObjectDeleteMixin, RESTObject):