TypeError: __init__() got an unexpected keyword argument ‘providing_args’

We Are Going To Discuss About TypeError: __init__() got an unexpected keyword argument ‘providing_args’. So lets Start this Python Article.

TypeError: __init__() got an unexpected keyword argument ‘providing_args’

  1. How to solve TypeError: __init__() got an unexpected keyword argument 'providing_args'

    Based on the comments, you're running Django 4.0 with an old version of AllAuth. So you just need to update AllAuth and should be fine.

    However, other people who have upgraded AllAuth and are running Django 4.0 but still seeing this error may have custom AllAuth or other signals registered that include the providing_args argument.
    In this case, you need to search your project for any signals (such as those often overridden in AllAuth: user_logged_in or email_changed) and remove the providing_args=['request', 'user', 'signup'] or other variation from the Signal parenthesis.
    See below for more information, and an example diff showing how you could move each providing_args argument to a commented line.

    Django deprecated the ability to use the providing_args argument to django.dispatch.Signal in Django 3.1. See bullet in the Misc section of the 3.1 release notes.
    It was removed because this argument doesn't do anything other than act as documentation. If that seems strange, it is because it is strange. Arguments should indicate data getting passed. This is probably why it was deprecated.
    Django 4.0 went ahead and removed this altogether, making any code that calls Signal() with the providing_args argument now trigger the TypeError you encountered:
    TypeError: Signal.__init__() got an unexpected keyword argument 'providing_args'
    AllAuth removed the use of this argument in September of 2020. (See original report on this issue here and the referenced diff)
    The person asking the question in this thread was running AllAuth 0.42.0 which does not include this change and is thus incompatible with Django 4.0.
    As of today, the last version of Django AllAuth 0.42.0 is compatible with is Django 3.2.9.

  2. TypeError: __init__() got an unexpected keyword argument 'providing_args'

    Based on the comments, you're running Django 4.0 with an old version of AllAuth. So you just need to update AllAuth and should be fine.

    However, other people who have upgraded AllAuth and are running Django 4.0 but still seeing this error may have custom AllAuth or other signals registered that include the providing_args argument.
    In this case, you need to search your project for any signals (such as those often overridden in AllAuth: user_logged_in or email_changed) and remove the providing_args=['request', 'user', 'signup'] or other variation from the Signal parenthesis.
    See below for more information, and an example diff showing how you could move each providing_args argument to a commented line.

    Django deprecated the ability to use the providing_args argument to django.dispatch.Signal in Django 3.1. See bullet in the Misc section of the 3.1 release notes.
    It was removed because this argument doesn't do anything other than act as documentation. If that seems strange, it is because it is strange. Arguments should indicate data getting passed. This is probably why it was deprecated.
    Django 4.0 went ahead and removed this altogether, making any code that calls Signal() with the providing_args argument now trigger the TypeError you encountered:
    TypeError: Signal.__init__() got an unexpected keyword argument 'providing_args'
    AllAuth removed the use of this argument in September of 2020. (See original report on this issue here and the referenced diff)
    The person asking the question in this thread was running AllAuth 0.42.0 which does not include this change and is thus incompatible with Django 4.0.
    As of today, the last version of Django AllAuth 0.42.0 is compatible with is Django 3.2.9.

Solution 1

Based on the comments, you’re running Django 4.0 with an old version of AllAuth. So you just need to update AllAuth and should be fine.


However, other people who have upgraded AllAuth and are running Django 4.0 but still seeing this error may have custom AllAuth or other signals registered that include the providing_args argument.

In this case, you need to search your project for any signals (such as those often overridden in AllAuth: user_logged_in or email_changed) and remove the providing_args=['request', 'user', 'signup'] or other variation from the Signal parenthesis.

See below for more information, and an example diff showing how you could move each providing_args argument to a commented line.


Django deprecated the ability to use the providing_args argument to django.dispatch.Signal in Django 3.1. See bullet in the Misc section of the 3.1 release notes.

It was removed because this argument doesn’t do anything other than act as documentation. If that seems strange, it is because it is strange. Arguments should indicate data getting passed. This is probably why it was deprecated.

Django 4.0 went ahead and removed this altogether, making any code that calls Signal() with the providing_args argument now trigger the TypeError you encountered:

TypeError: Signal.__init__() got an unexpected keyword argument 'providing_args'

AllAuth removed the use of this argument in September of 2020. (See original report on this issue here and the referenced diff)

The person asking the question in this thread was running AllAuth 0.42.0 which does not include this change and is thus incompatible with Django 4.0.

As of today, the last version of Django AllAuth 0.42.0 is compatible with is Django 3.2.9.

Original Author Rob Of This Content

Solution 2

I solved the same problem by replacing

check_request_enabled = Signal(providing_args=["request"])

to

check_request_enabled = Signal("request")

and now its working perfectly.

Original Author Nishith Shetty Of This Content

Solution 3

i don’t know why this happening but (it works on my machine) i solved the same problem by replacing

user_logged_in = Signal(providing_args=["request", "user"])

with

user_logged_in = Signal()

in /usr/local/lib/python3.9/site-packages/allauth/account/signals.py

Original Author Oussama Tachi Of This Content

Solution 4

This is for anyone who faces the same issue on Django 4.0 and is not using AllAuth.

I ran into a similar issue. However, I was not using AllAuth.
The problem is that Django 4.0 does not have any providing_args parameter, so the signal is declared this way.

from django.dispatch import Signal

model_delete_signal = Signal()

Now, you can send any arguments when sending the signal, which will be received in kwargs in the receiver.

For example, I sent the following instance argument while sending the signal in my custom delete function

model_delete_signal.send(sender='session_delete', instance=self)

and received it this way inside the receiver

@receiver(session_delete)
def delete_session(sender, **kwargs):
    instance = kwargs['instance']

Note that, the solution is the same for any Django versions that don’t have providing_args parameter in Singal()

Original Author Muhammad Zubair Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment