Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita404152

Browse files
nejchJohnVillalovos
authored andcommitted
docs(advanced): add hint on type narrowing
1 parent5b642a5 commita404152

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎docs/api-usage-advanced.rst‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,23 @@ parameter to that API invocation:
161161
162162
gl= gitlab.gitlab(url, token,api_version=4)
163163
gl.projects.import_github(ACCESS_TOKEN,123456,"root",timeout=120.0)
164+
165+
Typing
166+
------
167+
168+
Generally, ``python-gitlab`` is a fully typed package. However, currently you may still
169+
need to do some
170+
`type narrowing<https://mypy.readthedocs.io/en/stable/type_narrowing.html#type-narrowing>`_
171+
on your own, such as for nested API responses and ``Union`` return types. For example:
172+
173+
..code-block::python
174+
175+
from typingimportTYPE_CHECKING
176+
177+
import gitlab
178+
179+
gl= gitlab.gitlab(url, token,api_version=4)
180+
license= gl.get_license()
181+
182+
ifTYPE_CHECKING:
183+
assertisinstance(license["plan"],str)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp