You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mypy doesn't appear to handle generic parameters with default values correctly.
To Reproduce
fromtypingimportTypeVar, reveal_typeimportnumpyasnpfromnumpy.typingimportNBitBase, NDArrayT=TypeVar("T", bound=NBitBase)
deffunc(dtype: type[np.floating[T]] =np.float64) ->NDArray[np.floating[T]]: # error: Incompatible default for argument "dtype" (default has type "type[floating[Any]]", argument has type "type[floating[T]]") [assignment]returnnp.empty(1, dtype)
reveal_type(func()) # Revealed type is "numpy.ndarray[Any, numpy.dtype[numpy.floating[<nothing>]]]"reveal_type(func(np.float32)) # Revealed type is "numpy.ndarray[Any, numpy.dtype[numpy.floating[numpy._typing._32Bit]]]"
Expected Behavior
scratch.py:11: note: Revealed type is "numpy.ndarray[Any, numpy.dtype[numpy.floating[numpy._typing._64Bit]]]"
scratch.py:12: note: Revealed type is "numpy.ndarray[Any, numpy.dtype[numpy.floating[numpy._typing._32Bit]]]"
Actual Behavior
scratch.py:8: error: Incompatible default for argument "dtype" (default has type "type[floating[Any]]", argument has type "type[floating[T]]") [assignment]
scratch.py:11: note: Revealed type is "numpy.ndarray[Any, numpy.dtype[numpy.floating[<nothing>]]]"
scratch.py:12: note: Revealed type is "numpy.ndarray[Any, numpy.dtype[numpy.floating[numpy._typing._32Bit]]]"
Found 1 error in 1 file (checked 1 source file)
Your Environment
Mypy version used: 1.5.1
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): none
Bug Report
Mypy doesn't appear to handle generic parameters with default values correctly.
To Reproduce
Expected Behavior
Actual Behavior
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: