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

Add a getstatus() method to gidget.abc #194

Merged
merged 7 commits into from
May 4, 2023

Conversation

offbyone
Copy link
Contributor

This now supports API methods whose responses are expressed in a status
code, such as /orgs/{org}/members/{username} to determine if a group
contains a specific user.


Alternatives

Per the discussion on #188 this could have been achieved through refactoring _make_request() to split out request construction. Looking at the intermingling of the caching logic, the rate limit counter, and the header assembly, though, it looked like any method that made use of the full set of request construction would look remarkably similar to the full _make_request() call. As such, I augmented the return value to include the status code instead.

Closes #188

This now supports API methods whose responses are expressed in a status
code, such as `/orgs/{org}/members/{username}` to determine if a group
contains a specific user.

/cc gidgethub#188
@offbyone offbyone marked this pull request as draft April 24, 2023 18:33
@offbyone offbyone marked this pull request as ready for review April 24, 2023 20:51
@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2023

Codecov Report

Merging #194 (539f3a3) into main (20e8612) will not change coverage.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff            @@
##              main      #194   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          463       469    +6     
  Branches        86        86           
=========================================
+ Hits           463       469    +6     
Impacted Files Coverage Δ
gidgethub/__init__.py 100.00% <100.00%> (ø)
gidgethub/abc.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@offbyone
Copy link
Contributor Author

The linter failure is because of the deprecation of the intersphinx format, which feels like it's a bit out of scope for this PR. Can we skip that check, if the rest is fine?

@Mariatta
Copy link
Member

Thanks! Can you also update the changelog?

@Mariatta
Copy link
Member

and version number

docs/changelog.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

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

Overall I'm fine with the result, but two tweaks to make before the PR can be merged.

docs/changelog.rst Outdated Show resolved Hide resolved
docs/changelog.rst Outdated Show resolved Hide resolved
- bumped the minor version
- removed the extra changelog entry for 195
@offbyone offbyone requested a review from brettcannon May 3, 2023 23:34
@brettcannon brettcannon merged commit 901f057 into gidgethub:main May 4, 2023
@brettcannon
Copy link
Collaborator

Thanks!

@offbyone offbyone deleted the add-getstatus branch May 4, 2023 18:37
github-actions bot pushed a commit to aio-libs/aiohttp that referenced this pull request Aug 22, 2024
Bumps [gidgethub](https://github.com/brettcannon/gidgethub) from 5.0.1
to 5.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/brettcannon/gidgethub/releases">gidgethub's
releases</a>.</em></p>
<blockquote>
<h2>5.3.0</h2>
<ul>
<li>
<p>Add support passing <code>extra_headers</code> when making requests
[PR <a
href="https://redirect.github.com/brettcannon/gidgethub/issues/192">#192</a>](<a
href="https://redirect.github.com/brettcannon/gidgethub/pull/192">brettcannon/gidgethub#192</a>)</p>
</li>
<li>
<p>Add a getstatus() method for APIs that do not return content.
[PR <a
href="https://redirect.github.com/brettcannon/gidgethub/issues/194">#194</a>](<a
href="https://redirect.github.com/brettcannon/gidgethub/pull/194">brettcannon/gidgethub#194</a>)</p>
</li>
</ul>
<h2>5.2.1</h2>
<ul>
<li>
<p>Fix cgi and importlib_resources deprecations.
[PR <a
href="https://redirect.github.com/brettcannon/gidgethub/issues/185">#185</a>](<a
href="https://redirect.github.com/brettcannon/gidgethub/pull/185">brettcannon/gidgethub#185</a>)</p>
</li>
<li>
<p>Add support for Python 3.11 and drop EOL Python 3.6
[PR <a
href="https://redirect.github.com/brettcannon/gidgethub/issues/184">#184</a>](<a
href="https://redirect.github.com/brettcannon/gidgethub/pull/184">brettcannon/gidgethub#184</a>)</p>
</li>
</ul>
<h2>5.2.0</h2>
<ul>
<li>Make the minimum version of PyJWT be v2.4.0.</li>
</ul>
<h2>5.1.0</h2>
<ul>
<li>
<p>Use <code>X-Hub-Signature-256</code> header for webhook validation
when available.
([PR <a
href="https://redirect.github.com/brettcannon/gidgethub/issues/160">#160</a>](<a
href="https://redirect.github.com/brettcannon/gidgethub/pull/160">brettcannon/gidgethub#160</a>)).</p>
</li>
<li>
<p>The documentation is now built using Sphinx v&gt;= 4.0.0.
([Issue <a
href="https://redirect.github.com/brettcannon/gidgethub/issues/143">#143</a>](<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/143">brettcannon/gidgethub#143</a>))</p>
</li>
<li>
<p><code>gidgethub.abc.GitHubAPI.getiter</code> now accepts
<code>iterable_key</code> parameter
in order to support the Checks API.
([Issue <a
href="https://redirect.github.com/brettcannon/gidgethub/issues/164">#164</a>](<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/164">brettcannon/gidgethub#164</a>))</p>
</li>
<li>
<p>Accept HTTP 202 ACCEPTED as successful.
([PR <a
href="https://redirect.github.com/brettcannon/gidgethub/issues/174">#174</a>](<a
href="https://redirect.github.com/brettcannon/gidgethub/pull/174">brettcannon/gidgethub#174</a>))</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/gidgethub/gidgethub/blob/main/docs/changelog.rst">gidgethub's
changelog</a>.</em></p>
<blockquote>
<h2>5.3.0</h2>
<ul>
<li>
<p>Add support passing <code>extra_headers</code> when making requests
(<code>PR [#192](gidgethub/gidgethub#192)
&lt;https://github.com/brettcannon/gidgethub/pull/192&gt;</code>_)</p>
</li>
<li>
<p>Add a getstatus() method for APIs that do not return content.
(<code>PR [#194](gidgethub/gidgethub#194)
&lt;https://github.com/brettcannon/gidgethub/pull/194&gt;</code>_)</p>
</li>
</ul>
<h2>5.2.1</h2>
<ul>
<li>
<p>Fix cgi and importlib_resources deprecations.
(<code>PR [#185](gidgethub/gidgethub#185)
&lt;https://github.com/brettcannon/gidgethub/pull/185&gt;</code>_)</p>
</li>
<li>
<p>Add support for Python 3.11 and drop EOL Python 3.6
(<code>PR [#184](gidgethub/gidgethub#184)
&lt;https://github.com/brettcannon/gidgethub/pull/184&gt;</code>_)</p>
</li>
</ul>
<h2>5.2.0</h2>
<ul>
<li>Make the minimum version of PyJWT be v2.4.0.</li>
</ul>
<h2>5.1.0</h2>
<ul>
<li>
<p>Use <code>X-Hub-Signature-256</code> header for webhook validation
when available.
(<code>PR [#160](gidgethub/gidgethub#160)
&lt;https://github.com/brettcannon/gidgethub/pull/160&gt;</code>_).</p>
</li>
<li>
<p>The documentation is now built using Sphinx v&gt;= 4.0.0.
(<code>Issue [#143](gidgethub/gidgethub#143)
&lt;https://github.com/brettcannon/gidgethub/issues/143&gt;</code>_)</p>
</li>
<li>
<p>:meth:<code>gidgethub.abc.GitHubAPI.getiter</code> now accepts
<code>iterable_key</code> parameter
in order to support the Checks API.
(<code>Issue [#164](gidgethub/gidgethub#164)
&lt;https://github.com/brettcannon/gidgethub/issues/164&gt;</code>_)</p>
</li>
<li>
<p>Accept HTTP 202 ACCEPTED as successful.
(<code>PR [#174](gidgethub/gidgethub#174)
&lt;https://github.com/brettcannon/gidgethub/pull/174&gt;</code>_)</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/dbcdf4bd32de86288495dbbd8c1682399ba53ad1"><code>dbcdf4b</code></a>
Fix the rst markup on the Changelog. (<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/197">#197</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/b9fe3c69030e0960d4ba2dcc1efb921e240c7504"><code>b9fe3c6</code></a>
Add <code>extra_headers</code> option to <code>get</code> methods (<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/192">#192</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/901f0578c00919cdb8c0b120b6d9d9f35eda620e"><code>901f057</code></a>
Add a getstatus() method to gidgethub.abc (<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/194">#194</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/20e861254150b16bfd2fbe26b012cb6736430faf"><code>20e8612</code></a>
Update the intersphinx mapping to 1.0-style (<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/195">#195</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/e1f7baed601914139fc5179fcb8faea210bbf543"><code>e1f7bae</code></a>
Fix lint issues (<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/191">#191</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/b3ae8d16426355f660a2fc2aadeb4d8e61478add"><code>b3ae8d1</code></a>
Replace use of <code>requests</code> in examples with <code>httpx</code>
(<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/190">#190</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/4fe3c04d7c550a5b33fbf00e154810042f7d3edb"><code>4fe3c04</code></a>
Release 5.2.1 (<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/186">#186</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/89ade8859539212e0663e91f0777ad8a39ecf323"><code>89ade88</code></a>
Fix cgi and importlib_resources deprecations (<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/185">#185</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/64888cbe83e3f11af3c6f25294adff26dc2f557a"><code>64888cb</code></a>
Add support for Python 3.11 and drop EOL Python 3.6 (<a
href="https://redirect.github.com/brettcannon/gidgethub/issues/184">#184</a>)</li>
<li><a
href="https://github.com/gidgethub/gidgethub/commit/8c60e56029b7e10b7be9879e64dfbf97bbeda2b8"><code>8c60e56</code></a>
Add variable mapping to fix 'Session tests-3.10-dev skipped: Python
interpret...</li>
<li>Additional commits viewable in <a
href="https://github.com/brettcannon/gidgethub/compare/5.0.1...v5.3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=gidgethub&package-manager=pip&previous-version=5.0.1&new-version=5.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

Recover status code after request
4 participants