Skip to content

merge GithubObject.pyi/Requester.pyi stubs back to source#2463

Merged
JLLeitschuh merged 51 commits intoPyGithub:masterfrom
trim21:type
Jun 16, 2023
Merged

merge GithubObject.pyi/Requester.pyi stubs back to source#2463
JLLeitschuh merged 51 commits intoPyGithub:masterfrom
trim21:type

Conversation

@trim21
Copy link
Contributor

@trim21 trim21 commented Mar 20, 2023

ref #2462

@trim21 trim21 changed the title merge GithubObject stubs back to source merge GithubObject.pyi stubs back to source Mar 20, 2023
@trim21 trim21 marked this pull request as draft March 20, 2023 04:07
@codecov-commenter
Copy link

codecov-commenter commented May 8, 2023

Codecov Report

Patch coverage: 94.83% and project coverage change: -0.08 ⚠️

Comparison is base (6d4b6d1) 98.50% compared to head (ee1340c) 98.43%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2463      +/-   ##
==========================================
- Coverage   98.50%   98.43%   -0.08%     
==========================================
  Files         128      128              
  Lines       12757    12806      +49     
==========================================
+ Hits        12566    12605      +39     
- Misses        191      201      +10     
Impacted Files Coverage Δ
github/RepositoryAdvisory.py 93.83% <ø> (ø)
github/Requester.py 97.28% <93.05%> (-1.00%) ⬇️
github/GithubObject.py 96.42% <93.58%> (-2.42%) ⬇️
github/Authorization.py 98.94% <97.50%> (-1.06%) ⬇️
github/AccessToken.py 100.00% <100.00%> (ø)
github/GithubException.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@trim21 trim21 marked this pull request as ready for review May 23, 2023 20:08
@trim21 trim21 changed the title merge GithubObject.pyi stubs back to source merge GithubObject.pyi/Requester.pyi stubs back to source May 23, 2023
@EnricoMi EnricoMi requested a review from JLLeitschuh June 13, 2023 19:27
trim21 and others added 2 commits June 14, 2023 03:29
Co-authored-by: Enrico Minack <github@enrico.minack.dev>
@trim21
Copy link
Contributor Author

trim21 commented Jun 13, 2023

can you consider #2522 , so the ci will failed with better message? now pre-commit or mypy will all failed in py38 job

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.

This is a massive bit of work! I'm very impressed! Just a few minor things and I'm more than happy to merge this! 🎉

:rtype: None
"""
assert scopes is github.GithubObject.NotSet or all(
assert isinstance(scopes, _NotSetType) or all(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really don't like how this degenerates from

assert scopes is NotSet

to

assert isinstance(scopes, _NotSetType)

@JLLeitschuh any suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why it's a degenerate...

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's going from a constant comparison using is to an isinstance check, which means that the entire type hierarchy needs to be checked every time now, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@trim21 trim21 Jun 15, 2023

Choose a reason for hiding this comment

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

Oh yes, it impact performance.

But I don't think it's very necessary

and also UnSet is Attribute[None] now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean this aesthetically.

assert scopes is NotSet

Is readable,

assert isinstance(scopes, _NotSetType)

is ugly.

Plus, we need to import a private class _NotSetType. A lot of code has to be touched. The former was present before.

Copy link
Contributor Author

@trim21 trim21 Jun 15, 2023

Choose a reason for hiding this comment

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

But python typing system doesn't support this.

If I use emun as single value here, it can't pass mypy:

o: Attribute[Optional[int]] = NotSet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also Protocol doesn't support generic, so make Attribute a Protocol won't work.

I don't know if there is any way to avoid all these problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a good side of this, now you can write assert isinstance(v, (_NotSetType, str)) instead of assert v is NotSet or instance(v, str)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @trim21 here. There may not be a way to make the type checker happy moving forward. Im inclined to let us poke at trying to make this better in a followup PR

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!

@JLLeitschuh JLLeitschuh merged commit b6258f4 into PyGithub:master Jun 16, 2023
@trim21 trim21 deleted the type branch June 16, 2023 16:00
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.

4 participants