Skip to content

Conversation

@csoriano1618
Copy link
Contributor

When saving an issue we send the updated data only.

However the server expect at least one parameter to be provided,
otherwise it fails with an exception.

Check whether we have some update to send, otherwise skip
the update altogether.

When saving an issue we send the updated data only. 

However the server expect at least one parameter to be provided,
otherwise it fails with an exception.

Check whether we have some update to send, otherwise skip
the update altogether.
gitlab/mixins.py Outdated
"""
updated_data = self._get_updated_data()
# Nothing to update. Servers fails if sent an empty dict.
if len(updated_data.keys()) == 9:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the logic here? Where does the 9 come from?

Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whops, typo when creating the patch. It should be a 0.

gitlab/mixins.py Outdated
"""
updated_data = self._get_updated_data()
# Nothing to update. Server fails if sent an empty dict.
if len(updated_data.keys()) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

A more pythonic way to write this would be:

if not update_data:
    return

Could you update the code? Thanks again.

@csoriano1618
Copy link
Contributor Author

Thanks for the review, I didn't know en empty dictionary works with the "not".

@gpocentek gpocentek merged commit 0c3a6cb into python-gitlab:master Dec 16, 2017
@gpocentek
Copy link
Contributor

Thanks @csoriano1618 👍

zmike pushed a commit to zmike/bztogl that referenced this pull request Jul 5, 2019
python-gitlab/python-gitlab#389 means that
python-gitlab will raise an exception if save() is called with no
parameters. This sends a redundant parameter as a workaround.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants