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
merge GithubObject.pyi/Requester.pyi stubs back to source #2463
Conversation
Codecov ReportPatch coverage:
❗ 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
☔ View full report in Codecov by Sentry. |
Co-authored-by: Enrico Minack <github@enrico.minack.dev>
can you consider #2522 , so the ci will failed with better message? now pre-commit or mypy will all failed in py38 job |
Co-authored-by: Enrico Minack <github@enrico.minack.dev>
There was a problem hiding this 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! 🎉
@@ -136,45 +127,43 @@ def edit( | |||
:param note_url: string | |||
:rtype: None | |||
""" | |||
assert scopes is github.GithubObject.NotSet or all( | |||
assert isinstance(scopes, _NotSetType) or all( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
Co-authored-by: Jonathan Leitschuh <jonathan.leitschuh@gmail.com>
This reverts commit 4447be1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
ref #2462