-
Notifications
You must be signed in to change notification settings - Fork 258
Add 'singledispatch' to the __subclasscheck__ whitelist in the python2.7 port #405
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
There is a problem with If third party libraries want to use instance and class checks against subscripted generics, then they should develop their own functionality ( Finally, no changes will appear in typing 3.6.1, since this version should match exactly the typing module in Python 3.6.1 (the latter was already released). |
Would |
@JelleZijlstra It will help, but still some work should be done from the third party libraries side. However, if many people will ask for this, and there will be an agreement on semantics, then I think something like |
@ilevkivskyi: Thanks for your explanation. I agree that my proposed changed need not happen and that as @JelleZijlstra suggests How can I vote to add After that, the follow-up change that resolves this issue would be for Is that correct ? If so and if |
I would postpone this question until at least one version of
I can't say for sure, but adding anything |
Hm. Speaking on behalf of cattrs, we don't actually even need This error just happens since we basically do
so instead of just going directly to Hey, it says it's experimental right in the README :) |
Cool! - that means there should be no need for a change to either python/typing or singledispatch. I'll close this. |
Hi,
I'm trying to add python2.7 support to cattrs, which is an experimental library for converting Python data (see rtd for more detailed info).
cattrs uses typing.py for runtime conversions, along with singledispatch.
For the main python3 version of typing.py this works as expected. However, there is a discrepancy between the python2 port of typing.py and python3 version that breaks use of singledispatch in python2.
This check,
determines if a TypeError should be thrown when issubclass() is called on the parameterized type. If the calling code is from the 'functools' or 'abc' module then it's allowed. In python3, this allows the singledispatch function to dispatch on parametrized generic types.
However, in python2.7, the singledispatch function is not part of the functools module. It's provided in in a separate backport module named 'singledispatch'. Hence, that check currently fails in python2.7 in situations it would pass in python3.x.
A simple fix would be to add 'singledispatch' to the whitelist in the python2 port:
Please let me know if this change makes sense, I'm quite happy to send a PR to make the change.
If so, I'd like to try and get it done in time for the (3.6.1 release)[#403].
The text was updated successfully, but these errors were encountered: