-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Issue #33: convert to package and include typeshed type hints #34
Issue #33: convert to package and include typeshed type hints #34
Conversation
Codecov Report
@@ Coverage Diff @@
## master #34 +/- ##
=======================================
Coverage 95.34% 95.34%
=======================================
Files 1 1
Lines 365 365
Branches 29 29
=======================================
Hits 348 348
Misses 14 14
Partials 3 3
Continue to review full report at Codecov.
|
contextlib2/contextlib.pyi
Outdated
# type ignore to deal with incomplete ParamSpec support in mypy | ||
def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, _GeneratorContextManager[_T]]: ... # type: ignore | ||
|
||
if sys.version_info >= (3, 7): |
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.
Isn't this always defined in contextlib2?
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.
You could swap out all the if sys.version_info >= ...:
for if True:
to minimize the diff noise?
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.
Ah, true. And I like that suggestion for minimising the diff.
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.
The ABC will be a bit troublesome as you might need to import them from typing_extensions?
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 wasn't sure about that, as the typing module imports were unconditional in the typeshed version as well - it only guarded their aliasing to contextlib API entries.
I figured either mypy (et al) must be doing some shenanigans behind the scenes to let that work even on older Python versions, or else it needed to be fixed in typeshed first, and then contextlib2 could inherit that fix.
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.
Ah you're right, it's already in 3.6 https://docs.python.org/3.6/library/typing.html#typing.AsyncContextManager
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.
Heh, we both found the same info in about the same time, but picked different subthreads to update first :)
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.
Awesome, I'm very excited to use this!
You might want add type annotations for the deprecated classes and methods?
There are only two deprecated APIs, and I honestly suspect I should just remove them completely at this point: #31 (not in 21.6.0, though). I did enhance the CI to actually run mypy, though, and confirmed locally that it failed as expected if there was something wrong in the pyi file. So I'll merge this now, check everything over again in the morning, and assuming I don't think of anything else I missed, I'll cut the release tomorrow (And in writing that, I realised I need release notes for this change!) |
@graingert Ah, that would explain why mypy only complained when I introduced outright errors into the stub, and not when I only made it inconsistent with the actual implementation. |
No description provided.