Skip to content
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

event type use enum class #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

higumachan
Copy link

I use python enum class on "event_type". (https://docs.python.org/3.5/library/enum.html)

good points

  • Easy to browse the event list
  • If you use Pycharm or jedi or etc complementation tool then it will complement

@alexchamberlain
Copy link
Contributor

Thanks for the contribution @higumachan. My main thought when reviewing this is "Is this backwards compatible for existing users?"

Besides that, please review our CONTRIBUTING.md; it requires signing of commits to acknowledge the DCO et al. Please could you squash your commits into a single commit too?

@higumachan
Copy link
Author

higumachan commented Oct 27, 2017

Thanks for reply.

This is not compatible for exiting users.
I will fix it to compatible way.

I reviewed "CONTRIBUTING.md".
I will squash my commits and add DCO.

I use python enum class on "event_type". (https://docs.python.org/3.5/library/enum.html)

good points

Easy to browse the event list
If you use Pycharm or jedi or etc complementation tool then it will complement

There feature is downward compatibility.

Signed-Off-By: Yuta Hinokuma <[email protected]>
@higumachan
Copy link
Author

I fixed them.

Please could you review again?

Copy link

@edmorley edmorley left a comment

Choose a reason for hiding this comment

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

I wonder whether this change actually makes things more confusing for users, given there's now another indirection between what they see on the GitHub docs and here?

It seems there are two things that could be improved compared to what's on master:

  1. Making it easier for people to discover what hook names exist and what they do
  2. Making it harder for people to typo those names

For (1), if people aren't using an IDE that recognises this enum, then I think this PR actually makes things worse, since now they can't just look at the GitHub docs, they have to look at the source for this package. (Yes this PR backward compat supports the string format, but users probably won't know that)

For (2), instead of using enums, the package could instead just validate the names passed against a fixed list that matches the GitHub docs names. This would obviously have to be kept up to date, but no more so than this enum. An added bonus of this approach would be that it's not a backward incompatible change either.

@@ -8,7 +8,7 @@
author_email="[email protected], [email protected], [email protected], [email protected]",
license='Apache 2.0',
packages=["github_webhook"],
install_requires=['flask', 'six'],
install_requires=['flask', 'six', 'enum34'],

Choose a reason for hiding this comment

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

Perhaps use the python_version specifier here to limit this dependency to Python 2 only?


class EventType(Enum):
"""
Event enum type

Choose a reason for hiding this comment

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

I think it would be good to link to https://developer.github.com/v3/activity/events/types/ in the docstring so it shows up in the docs, plus anyone keeping this event list up to date in the future knows where to look

Repository = 'repository'
Status = 'status'
TeamAdd = 'team_add'
Watch = 'watch'

Choose a reason for hiding this comment

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

There are a half dozen events that are missing here compared to the list on:
https://developer.github.com/v3/activity/events/types/

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