-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make HTTPError instantiable. #1379
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
Conversation
stdlib/3/typing.pyi
Outdated
def __enter__(self) -> BinaryIO: ... | ||
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], | ||
# TODO: traceback should be TracebackType but that's defined in types | ||
traceback: Optional[Any]) -> bool: ... |
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.
TracebackType is already imported, so it should be fine to use.
Good point! Just copied that TODO from BinaryIO. Updated both locations to just use TracebackType. |
stdlib/3/typing.pyi
Outdated
@@ -404,6 +404,41 @@ class BinaryIO(IO[bytes]): | |||
@abstractmethod | |||
def __enter__(self) -> BinaryIO: ... | |||
|
|||
class _ConcreteBinaryIO(BinaryIO): |
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 don't think we should do this. Instead we should make some changes in io.pyi and inherit from io.BufferedRandom when we need a concrete subclass of BinaryIO.
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.
Ok, I'll see what I can put together that works.
So it turns out that just having |
So if addinfourl() inherits from io.BufferedIO, it's probably not compatible with something that requires a BinaryIO or IO[bytes]. I'm not sure if that's important? |
Ugh. Yeah, that probably matters. It also works to subclass I'll see what I can figure out with the |
Thanks, given that you only encountered it once it's not a high priority to get it fixed, so then I'd rather do it right or not at all (you can keep the |
@carljm any updates? |
This should be easier with the changes to io.pyi that just landed.
…On Jun 21, 2017 8:07 PM, "Jelle Zijlstra" ***@***.***> wrote:
@carljm <https://github.com/carljm> any updates?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1379 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMtCceIsdGvOnjWFVrqLBxaLXU0K2ks5sGdqKgaJpZM4NsijB>
.
|
I played with this for a bit but didn't get very far. If some of the io.pyi cleanup has been done for me, I'll take another look (probably next week). |
Great. Check out the changes that were made in
#1395
|
This was just reported again, so perhaps we should try to apply a quick fix to make HTTPError instantiable. Perhaps we can just drop the IO base class? |
Yeah, sorry... I took a look at this, realized that the io.pyi cleanup had only been done for Py2 and I care about Py3, so would have to figure out how to correctly reapply that cleanup for Py3, and then ran out of time. |
Ping? We should probably just close this if nobody's going to get to it. |
I'm not likely to get back to this soon, sorry. It's an unfortunate wart, but it doesn't crop up often (only one instance in our entire codebase AFAIK) and it's easy enough to |
OK, given the amount of back and forth this has already led to, I'm closing it. |
Fixes #1377.
Demonstration of fix (
../typeshed
is a clone of typeshed with this branch checked out):