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

Rework GithubIntegration #2556

Merged
merged 10 commits into from Jun 21, 2023
Merged

Conversation

EnricoMi
Copy link
Collaborator

Both github.Github and github.GithubIntegration are main entry points of this library. They create a Requester instance that handles all requests to the Github REST API. Requester has numerous arguments like base_url or timeout.

Firstly, Github and GithubIntegration should support the same (full) set of Requester arguments.

Secondly, creating a Github instance for a Github App Installation coming from GithubIntegration should use the same Requester arguments (except for auth). It should suffice to define base_url and other parameters once.

Fixes issues like #2455.

@EnricoMi EnricoMi added this to the Version 1.59.0 milestone Jun 19, 2023
@EnricoMi EnricoMi force-pushed the github-integration-rework-3 branch from f998c4e to 881f560 Compare June 19, 2023 08:47
Copy link
Collaborator

@JLLeitschuh JLLeitschuh left a comment

Choose a reason for hiding this comment

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

LGTM. One question about potentially API breaking changes though.

Comment on lines +32 to +37
timeout=Consts.DEFAULT_TIMEOUT,
user_agent=Consts.DEFAULT_USER_AGENT,
per_page=Consts.DEFAULT_PER_PAGE,
verify=True,
retry=None,
pool_size=None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an API breaking change if end users are using positional arguments

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is right. The rational here is the jwt_* arguments have been added quite recently and should be rarely used. So this breaks for little user code only, and is easy to fix. This will be flagged in the change log.

I favour similarity to github.Github signature here over not breaking this API for everyone.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is a, relatively, small class, could we delete this pyi file and move all the types over to the py file since you're already touching this file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd prefer to deal with that separately.

:param timeout: integer
:param user_agent: string
:param per_page: int
:param verify: boolean or string
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this document what values of verify there are? I don't know why this would ever be a str, or what values it would have

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I tracked it down. this eventually flows to requests.session which takes the verify argument and uses it. I understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this should reference requests.session in the docs, maybe one day in the future.

Comment on lines +61 to +63
self.assertEqual(
kwargs.keys(), github.Requester.Requester.__init__.__annotations__.keys()
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good test!

@EnricoMi EnricoMi force-pushed the github-integration-rework-3 branch from 881f560 to 494a930 Compare June 21, 2023 06:49
@EnricoMi EnricoMi merged commit ea45237 into PyGithub:main Jun 21, 2023
10 checks passed
@EnricoMi EnricoMi deleted the github-integration-rework-3 branch June 21, 2023 07:04
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.

None yet

2 participants