Skip to content

Commit

Permalink
Merge pull request #1038 from nejch/fix/allow-empty-create-data
Browse files Browse the repository at this point in the history
Fix: do not require empty data dict for create()
  • Loading branch information
max-wittig committed Mar 8, 2020
2 parents e5afb55 + 99d959f commit ca37d23
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/gl_objects/access_requests.rst
Expand Up @@ -37,8 +37,8 @@ List access requests from projects and groups::

Create an access request::

p_ar = project.accessrequests.create({})
g_ar = group.accessrequests.create({})
p_ar = project.accessrequests.create()
g_ar = group.accessrequests.create()

Approve an access request::

Expand Down
4 changes: 2 additions & 2 deletions docs/gl_objects/projects.rst
Expand Up @@ -103,7 +103,7 @@ Delete a project::

Fork a project::

fork = project.forks.create({})
fork = project.forks.create()

# fork to a specific namespace
fork = project.forks.create({'namespace': 'myteam'})
Expand Down Expand Up @@ -255,7 +255,7 @@ generated by GitLab you need to:

# Create the export
p = gl.projects.get(my_project)
export = p.exports.create({})
export = p.exports.create()

# Wait for the 'finished' status
export.refresh()
Expand Down
5 changes: 4 additions & 1 deletion gitlab/mixins.py
Expand Up @@ -170,7 +170,7 @@ def get_create_attrs(self):
return getattr(self, "_create_attrs", (tuple(), tuple()))

@exc.on_http_error(exc.GitlabCreateError)
def create(self, data, **kwargs):
def create(self, data=None, **kwargs):
"""Create a new object.
Args:
Expand All @@ -186,6 +186,9 @@ def create(self, data, **kwargs):
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server cannot perform the request
"""
if data is None:
data = {}

self._check_missing_create_attrs(data)
files = {}

Expand Down
2 changes: 1 addition & 1 deletion tools/python_test_v4.py
Expand Up @@ -949,7 +949,7 @@
[current_project.delete() for current_project in projects]

# project import/export
ex = admin_project.exports.create({})
ex = admin_project.exports.create()
ex.refresh()
count = 0
while ex.export_status != "finished":
Expand Down

0 comments on commit ca37d23

Please sign in to comment.