-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[2.7] urlparse.urlparse should use AnyStr, but can't due to NamedTuple #236
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
Comments
Not sure exactly what you are doing or what you are trying. Are you trying to fix something in the urlparse stubs? What exactly is the typeshed/2.7 directory? (I don't have one like that.) |
Hey @gvanrossum, thanks for looking at this. Yes, I am trying to improve the urlparse stubs. the I'm trying to model urlparse.urlparse() with a restricted generic type: if given a I'm having difficulty combining a restricted generic type with a Any assistance is appreciated :-) |
Oh, that's a tough puzzle. I wonder if this would be useful? from typing import *
class B(NamedTuple('B', [('a', Any)])):
pass
class C(NamedTuple('C', [('a', str)])):
pass
class D(NamedTuple('C', [('a', bytes)])):
pass
@overload
def foo(a: str) -> C:
pass
@overload
def foo(a: bytes) -> D:
pass
a = foo('')
reveal_type(a)
b = foo(b'')
reveal_type(b) But I don't know if that satisfies all requirements. |
@mr-c By the way, regardless of what you may or may not be doing wrong in a given program, mypy should never crash! :-) I just went and filed this one on the mypy tracker, as python/mypy#1682 , so we can fix it -- if you ever run into another crash, we'd always love to see it reported there. |
@gvanrossum Thanks, that worked! @gnprice Right-o, thank you for the reminder and for filing the follow up issue for me! |
Fair chance I'm doing something wrong here, any pointers?
The text was updated successfully, but these errors were encountered: