Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing arguments to position only on an override should be incompatible #13115

Closed
hackaugusto opened this issue Jul 13, 2022 · 1 comment
Closed
Labels
bug mypy got something wrong topic-inheritance Inheritance and incompatible overrides

Comments

@hackaugusto
Copy link
Contributor

Bug Report

To Reproduce

B.f below should be incompatible with A.f:

class A:
    def f(self, a: int) -> None:
        pass


class B(A):
    def f(self, a: int, /) -> None:
        pass

because the following fails:

def t(a: A) -> None:
    a.f(a=1)


t(B())

Expected Behavior

The signature of B.f should cause an error

Actual Behavior

No errors are reported

Your Environment

  • Mypy version used: mypy 0.961 (compiled: no) and mypy 0.980+dev.64a40e8487f591d57576396baaafae9e3a618555 (compiled: no)
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: Python 3.8.9
  • Operating system and version: macOS Monterey 12.4
@hackaugusto hackaugusto added the bug mypy got something wrong label Jul 13, 2022
@JelleZijlstra JelleZijlstra added the topic-inheritance Inheritance and incompatible overrides label Jul 13, 2022
@hauntsaninja
Copy link
Collaborator

Agreed that this is unsound, but it's a place where mypy has chosen to be pragmatic. It's not just positional-only args, the same sort of thing also applies to argument name changes:

class A:
    def f(self, a: int) -> None: ...

class B(A):
    def f(self, b: int) -> None: ...

Linking #1013

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-inheritance Inheritance and incompatible overrides
Projects
None yet
Development

No branches or pull requests

3 participants