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

Feature: allow parsing webhook with event name of type str #123

Merged
merged 1 commit into from
Aug 8, 2024
Merged

Feature: allow parsing webhook with event name of type str #123

merged 1 commit into from
Aug 8, 2024

Conversation

fau-st
Copy link
Contributor

@fau-st fau-st commented Aug 7, 2024

When calling the parse functions for webhooks, we don't always control where the name parameter comes from.
In my case, I retrieve it from a HTTP request's header and the type is simply str:

name: str = headers['X-GitHub-Event']
event = parse(name, b"")

And pyright complains with the following:
error: Type of "event" is unknown (reportUnknownVariableType)
error: No overloads for "parse" match the provided arguments (reportCallIssue)

However, since parse and parse_obj check for name to be part of VALID_EVENT_NAMES it looks safe to me to allow for plain str to be passed.

Let me know what you think.

@yanyongyu yanyongyu added enhancement New feature or request WebHook labels Aug 8, 2024
@yanyongyu
Copy link
Owner

I did miss the str type case. Thanks for your pr 😄

Copy link

codecov bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 17.65%. Comparing base (4f2e025) to head (cc9ac27).

Files Patch % Lines
...t/versions/ghec_v2022_11_28/webhooks/_namespace.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #123   +/-   ##
=======================================
  Coverage   17.65%   17.65%           
=======================================
  Files        4800     4800           
  Lines      222706   222706           
=======================================
  Hits        39316    39316           
  Misses     183390   183390           
Flag Coverage Δ
unittests 17.65% <50.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yanyongyu yanyongyu changed the title relax typing constraint when parsing webhook event name Feature: allow parsing webhook with event name of type str Aug 8, 2024
@yanyongyu yanyongyu merged commit 7083819 into yanyongyu:master Aug 8, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request WebHook
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants