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

feat: Add endpoint to fetch GitHub repository contributors #4013

Merged
merged 8 commits into from
May 24, 2024

Conversation

novakzaballa
Copy link
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Fetch GitHub repository contributors endpoint added.
Some Data Classes were optimized

How did you test this code?

Unit tests added to cover the new code

Copy link

vercel bot commented May 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 1:01pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 1:01pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 1:01pm

Copy link
Contributor

github-actions bot commented May 22, 2024

Uffizzi Preview deployment-52173 was deleted.

Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.29%. Comparing base (59ddfba) to head (3a9c6dc).
Report is 1 commits behind head on main.

Current head 3a9c6dc differs from pull request most recent head a811fdc

Please upload reports for the commit a811fdc to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4013   +/-   ##
=======================================
  Coverage   96.28%   96.29%           
=======================================
  Files        1143     1143           
  Lines       36992    37072   +80     
=======================================
+ Hits        35618    35698   +80     
  Misses       1374     1374           

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

Comment on lines 32 to 34
class PaginatedQueryParams(ABC):
page: int = field(default=1, init=False)
page_size: int = field(default=100, init=False)
Copy link
Member

Choose a reason for hiding this comment

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

  1. Why derive from ABC?
  2. Why init=False? What if we want to customise pagination?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Because I forgot we need to use it for a request and thought we would only need it as a base class for others. Now I changed it to a regular class and it's in use by the get repos endpoint.
  2. Because derivating without either init=false or kw_only gives an error. I now changed to use kw_only to have a better result.
    Thanks for cathing this out!

Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

LGTM in general with one question outstanding.

@novakzaballa
Copy link
Contributor Author

@khvn26 I solved your question, but that implied making some adjustments and improvements. Can you please re-review?

@novakzaballa novakzaballa requested a review from khvn26 May 23, 2024 20:03
Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

Three minor comments, otherwise LGTM.

# Then
assert response.status_code == status.HTTP_400_BAD_REQUEST
response_json = response.json()
if is_invalid_page:
Copy link
Member

Choose a reason for hiding this comment

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

An if inside a test is a code smell. I think it's better to have a parametrised detail or response_json argument instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, thanks! Done.

# Then
assert response.status_code == status.HTTP_400_BAD_REQUEST
response_json = response.json()
if is_invalid_page:
Copy link
Member

@khvn26 khvn26 May 24, 2024

Choose a reason for hiding this comment

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

Same here; consider parametrising detail or response_json argument instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

response: requests.Response,
total_count: int | None = None,
incomplete_results: bool | None = None,
) -> dict[str, Any]:
Copy link
Member

Choose a reason for hiding this comment

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

nit: It's not critical, but, since we fully control the creation of this dict, we could add a TypedDict return type to this function that would help introspection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe Dataclass or would it be too much? Let's please discuss this. Merging as is FTM.

@novakzaballa novakzaballa added this pull request to the merge queue May 24, 2024
Merged via the queue into main with commit 6f321d4 May 24, 2024
20 of 22 checks passed
@novakzaballa novakzaballa deleted the feat/fetch-github-contributors branch May 24, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants