An asynchronous GitHub API <https://docs.github.com/>
_ library.
.. image:: https://github.com/brettcannon/gidgethub/workflows/CI/badge.svg?event=push :target: https://github.com/brettcannon/gidgethub/actions
.. image:: https://codecov.io/gh/brettcannon/gidgethub/branch/master/graph/badge.svg :target: https://codecov.io/gh/brettcannon/gidgethub
.. image:: https://readthedocs.org/projects/gidgethub/badge/?version=latest :target: http://gidgethub.readthedocs.io/en/latest/ :alt: Documentation Status
Gidgethub is available on PyPI <https://pypi.org/project/gidgethub/>
_.
::
python3 -m pip install gidgethub
Gidgethub requires Python version 3.7 and up.
The key goal is to provide a base library for the
GitHub API <https://docs.github.com/>
which performs no I/O of its own (a
sans-I/O <https://sans-io.readthedocs.io/>
library). This allows users to
choose whatever HTTP library they prefer while parceling out GitHub-specific
details to this library. This base library is then built upon to provide an
abstract base class to a cleaner API to work with. Finally, implementations of
the abstract base class are provided for asynchronous HTTP libraries for
immediate usage.
If you think you want a different approach to the GitHub API,
GitHub maintains a list of libraries <https://docs.github.com/en/[email protected]/rest/overview/libraries>
_.
I couldn't think of a good name that was somehow a play on "GitHub" or somehow
tied into Monty Python <http://www.montypython.com/>
. And so I decided to play
off of GitHub's octocat <https://octodex.github.com/>
mascot and use my own
cat's name, Gidget, in some way. Since "Gidget" somewhat sounds like
"git", I decided to go with "gidgethub".
See the documentation for the full changelog <https://gidgethub.readthedocs.io/en/latest/changelog.html>
_.
https://peps.python.org/pep-0612/
This would enable rich type checking when calling the specific webhook handlers.
```py @ROUTER.register("installation") async def sync_installed_repos(event: Event, *, different_data: str) -> None: different_handler(event, different_data=computed_from(my_custom_data))
@ROUTER.register("installation_repositories") def different_handler(event: Event, *, my_custom_data: str): different_data = computed_from(my_custom_data) sync_installed_repos(event, different_data=different_data) ```
This would involve adding a dependency on typing_extensions or having a conditional definition of AsyncCallback
.
Hi!
I am using gidgethub
to create a bot within a GitHub App. I am struggling when checking whether a user is member of a certain organization, see GitHub documentation for this call.
From what I understood, gh.getitem
only returns the body of the request. However, the call mentioned above only returns a status code as a response (either 204, 302 or 404). Thus, I am not sure how to recover this status code after using await gh.getitem(url, oauth_token=oauth_token)
.
Please, let me know if I am misunderstanding something. Thanks!
E.g. https://gidgethub.readthedocs.io/en/latest/sansio.html#requests .
Try to use /search/issues. my query works good on guthub page. But I get problem in getitem
await gh.getitem(f"/search/issues?q=type:pr")
await gh.getitem(f"/search/issues?q=is::pr")
Get error - gidgethub.InvalidField: Validation Failed for 'q'
But
await gh.getitem(f"/search/issues?q=is:merged+type:pr")
works
Also my repo contains dots. And
await gh.getitem(f"/search/issues?q=repo:{name_with_dots}")
does not work.
My last params is date: merged:>YYYY-MM-DD
- it does not work too in gh.getitem
It looks so strange. Could you please help me with this problem?
im using gidgethub to push releases/artefacts.
if an artefact exists already it throws a gidgethub.InvalidField: Validation Failed for 'name'
if i catch the error, i have to reconnect (ie delete/create new) the session/GitHubAPI objects
im wondering if there is either a way to catch errors without the connection hosing, or a good/canonical way to reconnect if it does
This might be a duplicate of #107, but I thought I'd post anyway, since gidgethub
has been mostly intuitive to me, except for app authentication. I did see this comment, so, apologies in advance if this just isn't something you want to do.
Scenario: I'm making a bot for Spack, to ping maintainers about their packages. A user followed GitHub's tutorial and made a prototype bot in Ruby, but we're a Python project, and I wanted to make it easy for contributors to hack the bot in Python. I started with octomachinery, as it eliminates a fair bit of the boilerplate, but it is surprisingly (for a Python project) GPL3, so we cannot use it in Spack. I figured I'd just implement the auth myself since octomachinery
uses gidgethub
for much of the heavy lifting anyway.
Long story short, it took me a while to understand how to put everything in the GitHub guide together on the Python side. I had to:
Event
).I could not find resources that told me I had to make a JWT token and use that to get an installation access token based on each reqeust. @Mariatta's excellent bot tutorial seems to get OAuth tokens directly from the environment, instead of doing the JWT -> installation access token dance, as do the Bedevere and Miss Islington examples.
Maybe I am missing something about those, but it seems like the docs should have an example of how to use the GitHub app authentication flow, as I think most new bots will want to do this.
Anyway, thanks for Gidgethub!
Fix cgi and importlib_resources deprecations. PR #185
Add support for Python 3.11 and drop EOL Python 3.6 PR #184
Use X-Hub-Signature-256
header for webhook validation when available.
(PR #160).
The documentation is now built using Sphinx v>= 4.0.0. (Issue #143)
gidgethub.abc.GitHubAPI.getiter
now accepts iterable_key
parameter
in order to support the Checks API.
(Issue #164)
Accept HTTP 202 ACCEPTED as successful. (PR #174)
machine-man-preview
header from gidgethub.apps.get_installation_access_token
because it is out of preview. The machine-man-preview is no longer required as of August 20, 2020. Discussion #155gidgethub.routing.Router.fetch
for obtaining a frozenset of functions
registered to the router that the event would be called on.
Issue #74.gidgethub.actions.setenv
and gidgethub.actions.addpath
.
Issue #137.gidgethub.httpx.GitHubAPI._request
Issue #133.gidgethub.abc.GitHubAPI.post()
now accepts content_type parameter. If supplied, the content_type
value will be used in the request headers, and the raw form of the data will be passed to the request. If not supplied, by default the data will be parsed as JSON, and the “application/json”
content type will be used. (Issue #115).python github async sans-io treq twisted tornado aiohttp httpx