Skip to content

Add repo traffic support #972

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
merged 10 commits into from
Jan 6, 2020
Merged

Conversation

randomir
Copy link
Contributor

Addresses #971.

Before I add tests, please have a look at my stab for the repo traffic interface. Would you like something changed?

Copy link
Collaborator

@omgjlk omgjlk left a comment

Choose a reason for hiding this comment

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

This looks like a great start! Thank you for your submission!

You'll want to add yourself to the Authors file as well.

"""
params = {}
if per in ("day", "week"):
params.update(per=per)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if a user requests a per that is not one of day or week? There should probably be some checking around this and a raise if invalid options are passed.

Looking at the API itself, it does require a per argument, so it should be enough to validate that what the function was sent was one of day or week, and then just pass whatever it is into the params.

Maybe here, just have an else block that raises an error about invalid arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds reasonable. Will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although, to be consistent with this behavior, you'll want to update create_blob(), create_status(), create_tag() and archive() in the Repository class as well. All these functions accept parameters with a string value from some allowed set, and don't fail if the value is outside of that set (just silently ignore the parameter).

Copy link
Collaborator

Choose a reason for hiding this comment

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

That'd be a nice follow up PR.

Or maybe we can just follow the example. Presumably the API itself will return the error back to the user, and github3.py will surface it accordingly. Worth giving it a test! If the error comes back through nicely then less code is better code :D

"""
params = {}
if per in ("day", "week"):
params.update(per=per)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same thing here about validating a proper argument was sent.

@@ -600,6 +602,8 @@ def clones(self, per='day'):
params = {}
if per in ("day", "week"):
params.update(per=per)
else:
raise ValueError("per must be 'day' or 'week'")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like the right error to raise. But when adding a Raise we should update the function doc string. I was just looking at this example and saw the docs were updated there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, thanks for catching that.

Copy link
Collaborator

@omgjlk omgjlk left a comment

Choose a reason for hiding this comment

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

Great! I think all that's missing here is the tests, and adding yourself to the authors file! 🎉

@randomir
Copy link
Contributor Author

Thanks, @omgjlk, I'll add those soon(ish).

@randomir randomir force-pushed the add-traffic-support branch from 561103b to 8567956 Compare October 21, 2019 13:23
@randomir
Copy link
Contributor Author

Finally got to those tests. Thanks for your patience, @omgjlk.

@randomir randomir changed the title [WIP] Add repo traffic support Add repo traffic support Oct 25, 2019
@randomir
Copy link
Contributor Author

randomir commented Nov 4, 2019

Hey, @omgjlk, would you like me to add anything else to this PR? Or do you think it's ready to be merged? Thanks.

@randomir
Copy link
Contributor Author

@omgjlk, is there a reason why this PR has not yet been merged?

@omgjlk
Copy link
Collaborator

omgjlk commented Dec 19, 2019

@omgjlk, is there a reason why this PR has not yet been merged?

Sorry, I've just been distracted.

@omgjlk
Copy link
Collaborator

omgjlk commented Dec 19, 2019

Hrm, the appveyor checks are failing, but for unrelated reasons.

@randomir
Copy link
Contributor Author

randomir commented Jan 1, 2020

@omgjlk, this looks to be caused by the fact more-itertools==8.0.2 does not support py34. more-itertools dep is introduced by tox via importlib-metadata and zipp.

Is your intent to fix this in #978?

@omgjlk
Copy link
Collaborator

omgjlk commented Jan 3, 2020

@omgjlk, this looks to be caused by the fact more-itertools==8.0.2 does not support py34. more-itertools dep is introduced by tox via importlib-metadata and zipp.

Is your intent to fix this in #978?

Yes this is now fixed. I'm going to close and then re-open this PR in order to trigger new builds.

@omgjlk omgjlk closed this Jan 3, 2020
@omgjlk omgjlk reopened this Jan 3, 2020
@omgjlk omgjlk merged commit 25d911c into sigmavirus24:master Jan 6, 2020
@randomir randomir deleted the add-traffic-support branch November 1, 2021 15:04
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.

3 participants