Skip to content

Conversation

@austin-owensby
Copy link

@austin-owensby austin-owensby commented Jul 31, 2025

Summary

Remove the unused PyGithub dependency and make additional small updates.

Changes

  • Remove creation of Github instance object because it's not referenced after it's creation
  • Raise an exception when attempting to access the now deprecated gh property
  • Remove the GitHub token which was only used to create a GitHub instance object which has now been removed
  • Remove PyGithub dependency now that all references to it's use are removed
  • Add requests dependency which was previously installed with PyGithub
  • Replace deprecated utcfromtimestamp in unit tests
  • Add .gitignore to prevent unwanted files from making it into the code
  • Correct typos to increase professionalism of code

Impacts

  1. Because the connection to PyGithub has been removed, issue Make GITHUB_TOKEN unnecessary if private key is provided #5 is no longer needed.
  2. In that issue, it links to an external PR: Added development setup instructions to README.md EESSI/eessi-bot-software-layer#2 (comment) where it mentions that EESSI's requirement for a GitHub token comes from PyGHee's requirement. Now that this is being removed, EESSI should be reviewed to see if it's GITHUB_TOKEN requirement can also be removed.

@boegel
Copy link
Owner

boegel commented Aug 1, 2025

@austin-owensby Thank you for the contribution!

After a quick glance I think the changes you propose make sense, but I need to take a closer look at it and also try to remember why I introduced the self.gh attribute, since that's a breaking change to the PyGHee API, some projects that use PyGHee may be assuming that self.gh is still there.

I think it makes sense to have a gh property that raises an error to mention that this was removed, with some guidance on what to do instead (use PyGithub yourself to create a github.Github instance), do you mind looking into that too?

Also, out of interest: what triggered you to look into this, are you using PyGHee for something?

README.md Outdated
To run your GitHub App:

* Define environment variables for [GitHub Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and [GitHub app secret token](https://docs.github.com/en/developers/webhooks-and-events/securing-your-webhooks):
* Define an environment variables for the [GitHub app secret token](https://docs.github.com/en/developers/webhooks-and-events/securing-your-webhooks):
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
* Define an environment variables for the [GitHub app secret token](https://docs.github.com/en/developers/webhooks-and-events/securing-your-webhooks):
* Define an environment variable for the [GitHub app secret token](https://docs.github.com/en/developers/webhooks-and-events/securing-your-webhooks):

pyghee/lib.py Outdated
})

timestamp = datetime.datetime.utcfromtimestamp(int(event_info['timestamp_raw'])/1000.)
timestamp = datetime.datetime.fromtimestamp(int(event_info['timestamp_raw'])/1000., datetime.UTC)
Copy link
Owner

Choose a reason for hiding this comment

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

The datetime documentation recommends to use timezone.utc here, so let's do so?

Suggested change
timestamp = datetime.datetime.fromtimestamp(int(event_info['timestamp_raw'])/1000., datetime.UTC)
timestamp = datetime.datetime.fromtimestamp(int(event_info['timestamp_raw'])/1000., tz=datetime.UTC)

Copy link
Author

Choose a reason for hiding this comment

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

datetime.UTC is an alias for datetime.timezone.utc
https://docs.python.org/3/library/datetime.html#datetime.UTC

Copy link
Owner

Choose a reason for hiding this comment

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

OK, makes sense, but I'm still in favor of adding the tz= to make it explicit we're setting an optional value

Copy link
Author

Choose a reason for hiding this comment

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

Updated 👍

@austin-owensby
Copy link
Author

@austin-owensby Thank you for the contribution!

After a quick glance I think the changes you propose make sense, but I need to take a closer look at it and also try to remember why I introduced the self.gh attribute, since that's a breaking change to the PyGHee API, some projects that use PyGHee may be assuming that self.gh is still there.

I think it makes sense to have a gh property that raises an error to mention that this was removed, with some guidance on what to do instead (use PyGithub yourself to create a github.Github instance), do you mind looking into that too?

Also, out of interest: what triggered you to look into this, are you using PyGHee for something?

Yes I can look into that.

At work we were looking for a python library that could handle Webhooks from a GitHub App and make API calls to GitHub using the GitHub app's auth. This library popped up while Googling for something to use.

I think ultimately because our client is very stingy about GPL licenses, we won't end up using it, but I figured I'd hop in and make a small update.

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