8000 Make license attribute in response optional by electrofelix · Pull Request #804 · sigmavirus24/github3.py · GitHub
[go: up one dir, main page]

Skip to content

Make license attribute in response optional #804

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

electrofelix
Copy link
Contributor

Github Enterprise instances <= 2.12.7 do not include the license
attribute in responses for repository data. Allow this to be not set
and include a note in the documentation that the corresponding attr may
be set to None.

Partially fixes #794

@electrofelix
Copy link
Contributor Author

I had to manually manipulate this recording to remove the license key, so I need to find a way to avoid needing to do this as otherwise this can't be recreated and is just too kludgey, but hopefully it's a start and once I've ironed out how to test this case better, I can apply it for the other cases I come across as needed.

@electrofelix electrofelix force-pushed the convert-license-attr-optional branch from 6c26894 to ec47b71 Compare March 21, 2018 19:02
@sigmavirus24
Copy link
Owner

There's a lint error here.

I had to manually manipulate this recording to remove the license key

The files in tests/unit/json are not recordings. Mostly their copied directly from the GitHub API documentation. It's okay to manually edit those.

@electrofelix electrofelix force-pushed the convert-license-attr-optional branch from ec47b71 to 6b43242 Compare March 22, 2018 09:50
@electrofelix
Copy link
Contributor Author

@sigmavirus24 guess I should have mentioned after the last comment I worked out how to test this via the unit tests and force pushed an update, still just learning where everything is, sorry.

Github Enterprise instances <= 2.12.7 do not include the license
attribute in responses for repository data. Allow this to be not set
and include a note in the documentation that the corresponding attr may
be set to None.

Partially fixes sigmavirus24#794
@electrofelix electrofelix force-pushed the convert-license-attr-optional branch from 6b43242 to 08b1488 Compare March 22, 2018 09:51
@@ -2447,7 +2455,7 @@ def _update_attributes(self, repo):
self.has_wiki = repo['has_wiki']
self.homepage = repo['homepage']
self.language = repo['language']
self.original_license = repo['license']
self.original_license = repo.get('license', None)
Copy link
Owner

Choose a reason for hiding this comment

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

repo.get() returns None implicitly. Can you share why you specified None explicitly here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

purely to match the code style at

self.parent = repo.get('parent', None)
if self.parent is not None:
self.parent = ShortRepository(self.parent, self)
and
self.source = repo.get('source', None)
if self.source is not None:
self.source = ShortRepository(self.source, self)

Have no attachment to doing it that way, should I update all 3 calls to use the same approach? Or just this new occurrence?

Copy link
Owner

Choose a reason for hiding this comment

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

Might as well update all of them. I don't know what I was thinking. 😆

@sigmavirus24 sigmavirus24 merged commit 4c19805 into sigmavirus24:develop Mar 24, 2018
@sigmavirus24
Copy link
Owner

In retrospect I'm not that fussed either way about .get(key, None). It can be fixed up some other time.

@electrofelix electrofelix deleted the convert-license-attr-optional branch March 26, 2018 13:42
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
0