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

Unexpected error when inheriting a class from Popen and overriding some method in it #7597

Closed
actionless opened this issue Oct 1, 2019 · 1 comment · Fixed by #7656
Closed
Assignees
Labels
bug mypy got something wrong priority-0-high

Comments

@actionless
Copy link

  • Are you reporting a bug, or opening a feature request?
    Bug

  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.

import subprocess
from typing import List, Tuple


class MyPopen(subprocess.Popen):

    def communicate(self, _input=None, _timeout=None) -> Tuple[bytes, bytes]:
        return super().communicate(_input, _timeout)

def interactive_spawn(cmd: List[str], **kwargs) -> MyPopen:
    process = MyPopen(cmd, **kwargs)
    process.communicate()
    return process
  • What is the actual behavior/output?
$ mypy mypy_subprocess.py
mypy_subprocess.py:13: error: Incompatible return value type (got "Popen[Any]", expected "MyPopen")
Found 1 error in 1 file (checked 1 source file)
  • What is the behavior/output you expect?
$ mypy mypy_subprocess.py
Success: no issues found in 1 source file
  • What are the versions of mypy and Python you are using?
    Do you see the same issue after installing mypy from Git master?
$ mypy --version
mypy 0.730
(env) $ mypy --version
mypy 0.740+dev.583b99e5096c979043a63dcf92bf3f0d5993d03a

NOTE: it's not reproducing with 0.720

$ python --version
Python 3.7.4
  • What are the mypy flags you are using? (For example --strict-optional)
  • If mypy crashed with a traceback, please paste
    the full traceback below.
@actionless actionless changed the title Unexpected error when inveriting object from Popen and overriding some method Unexpected error when inheriting a class from Popen and overriding some method in it Oct 2, 2019
@msullivan msullivan self-assigned this Oct 2, 2019
@msullivan
Copy link
Collaborator

Yeah this got introduced in 0.730. I need to spend some time tweaking the rules for __new__ return types maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-0-high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants