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

--warn-return-any not applied to generics #10487

Open
farmio opened this issue May 16, 2021 · 0 comments
Open

--warn-return-any not applied to generics #10487

farmio opened this issue May 16, 2021 · 0 comments
Labels
bug mypy got something wrong

Comments

@farmio
Copy link

farmio commented May 16, 2021

Bug Report

When a function annotated to return tuple[T] returns tuple[Any] no error is raised. Same with list.

To Reproduce

from __future__ import annotations
from typing import Any

def passes() -> tuple[str]:
    a: Any
    return (a,)

def fails_1() -> tuple[str]:
    a: int
    return (a,)
    # error: Incompatible return value type (got "Tuple[int]", expected "Tuple[str]")

def fails_2() -> str:
    a: Any
    return a
    # error: Returning Any from function declared to return "str"

Expected Behavior

I'd expect passes() to fail with error: Returning Tuple[Any] from function declared to return "Tuple[str]" when using mypy with --strict

Actual Behavior

Tuple[Any] is inferred to Tuple[str]

Your Environment

  • Mypy version used: 0.812
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files):
# setup.cfg
[mypy]
python_version = 3.8
strict = true
warn_unreachable = true
implicit_reexport = true
ignore_missing_imports = true
  • Python version used: 3.9.1
  • Operating system and version: macOS 10.13.6
@farmio farmio added the bug mypy got something wrong label May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant