Skip to content

stubtest: Spurious warning when using Protocol types #13001

Closed as not planned
Closed as not planned
@dalcinl

Description

@dalcinl

Bug Report

stubtest produces spurious warning about __init__ in subclasses of typing.Protocol, despite the subclass not defining __init__.

To Reproduce

# preparation
cd /tmp
rm -rf foo && mkdir foo
touch foo/__init__.py
echo "from typing import Protocol" > foo/bar.py
echo "class Bar(Protocol):"       >> foo/bar.py
echo "    def meth(self): pass"   >> foo/bar.py
cp foo/bar.py foo/bar.pyi

# test
PYTHONPATH=$PWD stubtest foo

Expected Behavior

No output.

Actual Behavior

Output the following warning:

error: foo.bar.Bar.__init__ is inconsistent, stub does not have *args argument "args"
Stub: at line 87
def (self: builtins.object)
Runtime: at line 1429 in file /usr/lib64/python3.10/typing.py
def (self, *args, **kwargs)

Your Environment

  • Mypy version used: 0.961
  • Mypy command-line flags: none, as shown in the reproducer
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10.5
  • Operating system and version: Linux, Fedora 36.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions