Skip to content

stubgen removes Protocol from base classes list #12072

Description

@citruz

Bug Report

Consider the following input:

fromtypingimportProtocolclassInterface(Protocol):
defdummy(self, arg: str) ->str:
...

stubgen produces:

classInterface:
defdummy(self, arg: str) ->str: ...

Note that the Protocol class is removed from the list of base classes.

Obviously this causes problems when performing type checking against users of that generated typestub:

frominterfaceimportInterfaceclassInterfaceImpl:
defdummy(self, arg: str) ->str:
returnarginterf: Interface=InterfaceImpl()

mypy:

provider/__init__.py:8: error: Incompatible types in assignment (expression has type "InterfaceImpl", variable has type "Interface")

Expected Behavior

Protocol base class is not removed.

Actual Behavior

Protocol base class is removed.

Your Environment

  • Mypy version used: mypy 0.931
  • Python version used: Python 3.9.7
  • Operating system and version: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions