Skip to content

Lack of typing info #1588

Closed
Closed
@dAnjou

Description

@dAnjou

Hi, while using the library I've noticed some lack of typing info.

Given the following code in a file called gl.py:

from gitlab import Gitlab
from gitlab.v4.objects import CurrentUser

def get_current_user(gl: Gitlab) -> CurrentUser:
    gl.auth()
    return gl.user

def get_project(gl: Gitlab, name: str) -> str:
    return gl.projects.get(name).path

def get_user(gl: Gitlab, name: str) -> str:
    return gl.users.list(username=name)[0].username

def get_group(gl: Gitlab, name: str) -> str:
    return gl.groups.get(name).path

if __name__ == '__main__':
    gl = Gitlab('https://gitlab.com', private_token='xxx')
    user = get_current_user(gl)
    print(user.username)
    print(get_project(gl, "gitlab-org/gitlab"))
    print(get_user(gl, "dAnjou"))
    print(get_group(gl, "gitlab-org"))

The command mypy --strict gl.py returns a few errors:

gl.py:1: error: Module "gitlab" does not explicitly export attribute "Gitlab"; implicit reexport disabled
gl.py:2: error: Module "gitlab.v4.objects" does not explicitly export attribute "CurrentUser"; implicit reexport disabled
gl.py:11: error: Returning Any from function declared to return "str"
gl.py:15: error: Returning Any from function declared to return "str"
gl.py:19: error: Returning Any from function declared to return "str"
Found 5 errors in 1 file (checked 1 source file)
  • python-gitlab==2.10.1
  • default API version 4 on gitlab.com

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions