Skip to content

Default value of keyword parameter in custom Protocol is not used #10484

Open
@AndrewUshakov

Description

@AndrewUshakov

Bug Report

Consider the code below:

from typing import Protocol


class P(Protocol):
    def foo(self, n: int = 666) -> None: ...


class F:
    def foo(self, n: int = 666) -> None: ...


class S:
    def foo(self, n: int = 999) -> None: ...


def bar(x: P) -> None: ...


bar(F())
bar(S())

Expected Behavior

Warning in the last code line about incompatibility of class S and protocol P, because the default value of parameter n in P.foo is not ellipsis and the numerical value of n in S.foo is different.

Actual Behavior

Mypy does not generate any warnings.

Your Environment

  • Mypy version used:

8.12
0.820+dev.8642b351cff94c471333256f9cd6867807384f01

  • Mypy command-line flags:

none

  • Mypy configuration options from mypy.ini (and other config files):
[mypy]

pretty = True
show_error_codes = True
strict = True
disallow_any_unimported = True
disallow_any_expr = True
disallow_any_decorated = True
disallow_any_explicit = True
no_warn_no_return = True
warn_unreachable = True
  • Python version used:

3.8.10 (64-bit), 3.9.5 (64-bit), 3.10 beta (64-bit)

  • Operating system and version:

Windows 10 64-bit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions