Issue using Protocol as a base class with Python 3.5.2 · Issue #734 · python/typing · GitHub
Skip to content

Issue using Protocol as a base class with Python 3.5.2 #734

Description

@Slonegg

Python: 3.5.2
OS: macOS Mojave

Seems that _generic_new implementation from typing_extensions module is outdated or incorrect. When typing_extensions relies on its own implementation of _generic_new I get the following error.

Script to reproduce:

import abc
from typing_extensions import Protocol, runtime_checkable


@runtime_checkable
class Proto(Protocol):
    @abc.abstractmethod
    def foo(self):
        pass


class SomeClass(Proto):
    def __init__(self, some_arg):
        pass

    def foo(self):
        return 5


x = SomeClass(3)

Traceback:

Traceback (most recent call last):
  File "/Users/dikobraz/repro.py", line 20, in <module>
    x = SomeClass(3)
  File "/Users/dikobraz/env-py-3.5-tf-2/lib/python3.5/site-packages/typing_extensions.py", line 1357, in __new__
    return _generic_new(cls.__next_in_mro__, cls, *args, **kwds)
  File "/Users/dikobraz/env-py-3.5-tf-2/lib/python3.5/site-packages/typing_extensions.py", line 87, in _generic_new
    return base_cls.__new__(cls, *args, **kwargs)
TypeError: object() takes no parameters

In debugger:
Screen Shot 2020-06-23 at 6 47 37 PM

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions