Skip to content
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

simplegeneric => singledispatch: backward compatibility #62

Closed
franzlst opened this issue Jun 11, 2019 · 6 comments
Closed

simplegeneric => singledispatch: backward compatibility #62

franzlst opened this issue Jun 11, 2019 · 6 comments

Comments

@franzlst
Copy link
Contributor

With the change from simplegeneric to singledispatch, gaphas is no longer backward compatible with code that registers custom types, as you now need to call register instead of when_type.

This is fine, as you increase the minor version.

I was just wondering, whether you think there is an easy way for other software not requiring any code changes. Maybe somehow monkeypatching singledispatch? Doesn't sound like the best solution :-D

@amolenaar
Copy link
Member

I ran into the same issue when I tried running Gaphor with the Gaphas-master. I haven't sorted out a nice way to do it.

I agree that monkey-patching should not be the way to go, but in order to not break the interface, when_type() should be present somehow. If when_type would be available, it should go with a big deprecation warning, as I like to get rid of it ASAP.

@amolenaar
Copy link
Member

I added a small compatibility layer in adf3bdc.

@franzlst
Copy link
Contributor Author

Cool! And a clean solution 👍

@franzlst
Copy link
Contributor Author

when_type was accepting multiple types/classes, your wrapper only accepts one. Maybe you could change this...? 😳 😶

@amolenaar
Copy link
Member

I think that's easy to update. I did not dig that deep into the when_type api :).

BTW. The GenericType.default property is no longer there, so that would require a change. I'm not sure if we should add that back as well (preferably not).

@franzlst
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants