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

Fix: do not require empty data dict for create()#1038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
max-wittig merged 1 commit intopython-gitlab:masterfromnejch:fix/allow-empty-create-data
Mar 8, 2020
Merged

Fix: do not require empty data dict for create()#1038

max-wittig merged 1 commit intopython-gitlab:masterfromnejch:fix/allow-empty-create-data
Mar 8, 2020

Conversation

nejch
Copy link
Member

There's a quirk in theCreateMixin when checking for required attributes in_check_missing_create_attrs, which requires a data dict. But some create methods don't require additional data, e.g. if the only required attribute is already provided by their parent manager id (e.g. for project export, seehttps://docs.gitlab.com/ee/api/project_import_export.html).

This means the docs are sometimes asking people to pass an empty dict which I think is confusing for newcomers (and maybe unpythonic?).

This small fix allows usingcreate() without passing a dict. TheUpdateMixin is doing something similar withnew_data = new_data or {} but I thought this is a bit more explicit with None.

I didn't add any checks as the data is already validated in_check_missing_create_attrs based on each Manager's_create_attrs and is already tested (see below), so I hope I covered everything :)

deftest_create_mixin_missing_attrs(self):
classM(CreateMixin,FakeManager):
_create_attrs= (("foo",), ("bar","baz"))
mgr=M(self.gl)
data= {"foo":"bar","baz":"blah"}
mgr._check_missing_create_attrs(data)
data= {"baz":"blah"}
withself.assertRaises(AttributeError)aserror:
mgr._check_missing_create_attrs(data)
self.assertIn("foo",str(error.exception))
.

@max-wittig
Copy link
Member

You're right. This was kinda unpythonic before. Thanks for the change!

@max-wittigmax-wittig merged commitca37d23 intopython-gitlab:masterMar 8, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@nejch@max-wittig

[8]ページ先頭

©2009-2025 Movatter.jp