mypy icon indicating copy to clipboard operation
mypy copied to clipboard

MyPy doesn't report any errors when using TypeVars within TypeVar constraints

Open dadus33 opened this issue 1 year ago • 1 comments

Bug Report

According to this, using TypeVars to constraint other TypeVars is not possible. However, MyPy doesn't report any errors in such cases.

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.11&gist=e4febb3ef7aeaa11ea0aaabd4a068739

Expected Behavior

Some error should be reported

Actual Behavior

No error is reported

Your Environment

  • Mypy version used: 1.9.0
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.11

dadus33 avatar Apr 17 '24 16:04 dadus33

FWIW, I just updated the typing spec conformance tests to validate this part of the spec. Previously, the tests were attempting to validate this, but they were written in a way that masked the false negative in mypy. The updated tests correctly identify this conformance failure, and this is reflected in the latest conformance results summary.

erictraut avatar Apr 17 '24 17:04 erictraut