-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
featurepriority-1-normaltopic-type-aliasTypeAlias and other type alias issuesTypeAlias and other type alias issuestopic-usability
Description
Given:
from typing import Tuple
from math import hypot
Point = Tuple[float, ...]
Centroid = Point
def dist(p: Centroid, q: Point) -> float:
px, py = p
qx, qy = q
return hypot(px - qx, py - qy)
print( dist('xyz', (3.5, 7.2)) )
mypy detect the incorrect first argument:
$ mypy tmp.py
tmp.py:12: error: Argument 1 to "dist" has incompatible type "str"; expected Tuple[float, ...]
However, it would be much nicer is the error reporting could have used the alias name:
tmp.py:12: error: Argument 1 to "dist" has incompatible type "str"; expected "Centroid", which expands to Tuple[float, ...]
I realize it may be easy to do, but it would improve the usability of aliases.
mgedmin, dmwyatt, joguSD, Fulguritude, NeilGirdhar and 2 moremgedmin, joguSD and Fulgurituderampaq
Metadata
Metadata
Assignees
Labels
featurepriority-1-normaltopic-type-aliasTypeAlias and other type alias issuesTypeAlias and other type alias issuestopic-usability