Skip to content

Commit d9dea5f

Browse files
JukkaLmsullivan
authored andcommitted
Don't shorten long generic types in messages (python#7997)
Shortened names can be confusing.
1 parent 23a719f commit d9dea5f

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

mypy/messages.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,15 +1438,11 @@ def format(typ: Type) -> str:
14381438
return '{}[{}]'.format(alias, ', '.join(items))
14391439
else:
14401440
# There are type arguments. Convert the arguments to strings.
1441-
# If the result is too long, replace arguments with [...].
14421441
a = [] # type: List[str]
14431442
for arg in itype.args:
14441443
a.append(format(arg))
14451444
s = ', '.join(a)
1446-
if len((base_str + s)) < 150:
1447-
return '{}[{}]'.format(base_str, s)
1448-
else:
1449-
return '{}[...]'.format(base_str)
1445+
return '{}[{}]'.format(base_str, s)
14501446
elif isinstance(typ, TypeVarType):
14511447
# This is similar to non-generic instance types.
14521448
return typ.name

test-data/unit/check-generics.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ Z = TypeVar('Z')
13491349
class OO: pass
13501350
a = None # type: A[object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object]
13511351

1352-
f(a) # E: Argument 1 to "f" has incompatible type "A[...]"; expected "OO"
1352+
f(a) # E: Argument 1 to "f" has incompatible type "A[object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object]"; expected "OO"
13531353

13541354
def f(a: OO) -> None:
13551355
pass
@@ -2337,4 +2337,3 @@ class Test():
23372337
reveal_type(MakeTwoAppliedSubAbstract()(2)) # N: Revealed type is '__main__.TwoTypes[builtins.str, builtins.int*]'
23382338
reveal_type(MakeTwoGenericSubAbstract[str]()('foo')) # N: Revealed type is '__main__.TwoTypes[builtins.str, builtins.str*]'
23392339
reveal_type(MakeTwoGenericSubAbstract[str]()(2)) # N: Revealed type is '__main__.TwoTypes[builtins.str, builtins.int*]'
2340-

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy