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

TypeError makes ReadWriteScopedResourceMixin unusable #694

Open
broxane opened this issue Feb 22, 2019 · 0 comments
Open

TypeError makes ReadWriteScopedResourceMixin unusable #694

broxane opened this issue Feb 22, 2019 · 0 comments

Comments

@broxane
Copy link

broxane commented Feb 22, 2019

A class inheriting ReadWriteScopedResourceMixin (or ReadWriteScopedResourceView) , like this one

class A(ReadWriteScopedResourceMixin): 
    def __init__(self, *args, **kwargs): 
        self.args = args 
        self.kwargs = kwargs
        return super().__init__(*args, **kwargs)

It is possible to instantiate it without parameters a = A(), but raises a TypeError with parameters

>>> a = A(True, bar=foo)
TypeError: object() takes no parameters

In particular, this makes the classes incompatible with DRF viewsets

  File ".../python3.6/site-packages/rest_framework/viewsets.py", line 70, in view
    self = cls(**initkwargs)
  File ".../python3.6/site-packages/oauth2_provider/views/mixins.py", line 239, in __new__
    return super(ReadWriteScopedResourceMixin, cls).__new__(cls, *args, **kwargs)

I believe this is due to oauth2_provider/views/mixins.py line 239, the call

return super(ReadWriteScopedResourceMixin, cls).__new__(cls, *args, **kwargs)

should be

return super(ReadWriteScopedResourceMixin, cls).__new__(cls)

I use django-oauth-toolkit v 0.12.0, python 3.6, django 1.11.16 and drf 3.4.7

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

1 participant