question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR: object.__init__() takes no parameters

See original GitHub issue

Hello guys when I try to open connection from my frontend to my socket this error I get can you help me?

2020-12-05 15:00:37,612 ERROR    Exception inside application: object.__init__() takes no parameters
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/channels/routing.py", line 71, in __call__
    return await application(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/channels/sessions.py", line 47, in __call__
    return await self.inner(dict(scope, cookies=cookies), receive, send)
  File "/usr/local/lib/python3.6/site-packages/channels/sessions.py", line 254, in __call__
    return await self.inner(wrapper.scope, receive, wrapper.send)
  File "/usr/local/lib/python3.6/site-packages/channels/auth.py", line 181, in __call__
    return await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/channels/middleware.py", line 26, in __call__
    return await self.inner(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/channels/routing.py", line 160, in __call__
    send,
  File "/usr/local/lib/python3.6/site-packages/asgiref/compatibility.py", line 33, in new_application
    instance = application(scope)
  File "/usr/local/lib/python3.6/site-packages/channels/generic/websocket.py", line 159, in __init__
    super().__init__(*args, **kwargs)
TypeError: object.__init__() takes no parameters

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
johnbettscommented, Feb 25, 2021

I had the same issue, though found this article that basically stated update routing.py to add .as_asgi() to my consumer consumers.LivePostConsumer.as_asgi()),

0reactions
dmugtasimovcommented, Feb 25, 2021

It is to be fixed here: channels.testing.websocket.WebsocketCommunicator

    def __init__(self, application, path, headers=None, subprotocols=None):
        if not isinstance(path, str):
            raise TypeError("Expected str, got {}".format(type(path)))
        parsed = urlparse(path)
        self.scope = {
            "type": "websocket",
            "path": unquote(parsed.path),
            "query_string": parsed.query.encode("utf-8"),
            "headers": headers or [],
            "subprotocols": subprotocols or [],
        }
        super().__init__(application, self.scope)

Scope should not be passed as described in the release notes: https://channels.readthedocs.io/en/latest/releases/3.0.0.html

Consumers are now ASGI 3 single-callables with the signature:

application(scope, receive, send)
For generic consumers this change should be largely transparent, but you will need to update __init__() (no longer taking the scope) and __call__() (now taking the scope) if you implemented these yourself.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python inheritance: TypeError: object.__init__() takes no ...
Essentially what you are resolving to is the __init__ of the object base class which takes no params. Its a bit redundant, I...
Read more >
TypeError: object.__init__() takes no parameters - Python
I'm having trouble a TypeError. Whenever I create a new HighSchool object I get the error: “TypeError: object.init() takes no parameters”.
Read more >
Python inheritance TypeError object init takes no parameters
I get this error: TypeError: object.__init__() takes no parameters. when running my code, I don't really see what I'm doing wrong here ...
Read more >
TypeError: object.__init__() takes no parameters - menno.io
__init__ no longer take arguments - a TypeError is raised when arguments are passed. To avoid breaking too much pre-existing code, there is...
Read more >
TypeError: Class() takes no arguments in Python
To solve the error, make sure to define the `__init__()` (two ... The Python "TypeError: Class() takes no arguments" occurs when we forget ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found