| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5b642a5 commit a404152
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -161,3 +161,23 @@ parameter to that API invocation: | |||
| 161 | 161 | ||
| 162 | 162 | gl = gitlab.gitlab(url, token, api_version=4) | |
| 163 | 163 | 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 typing import TYPE_CHECKING | ||
| 176 | + | ||
| 177 | + import gitlab | ||
| 178 | + | ||
| 179 | + gl = gitlab.gitlab(url, token, api_version=4) | ||
| 180 | + license = gl.get_license() | ||
| 181 | + | ||
| 182 | + if TYPE_CHECKING: | ||
| 183 | + assert isinstance(license["plan"], str) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments