@@ -1603,7 +1603,8 @@ class C:
16031603 pass
16041604
16051605def f(cls: Type[P]) -> P:
1606- return cls() # E: Cannot instantiate protocol class "P"
1606+ return cls() # E: Cannot instantiate protocol class "P" \
1607+ # N: Consider using "Callable[..., P]" instead of "type[P]"
16071608def g() -> P:
16081609 return P() # E: Cannot instantiate protocol class "P"
16091610
@@ -1625,7 +1626,8 @@ class C:
16251626 pass
16261627
16271628def f(cls: Type[P]) -> P:
1628- return cls() # E: Cannot instantiate protocol class "P"
1629+ return cls() # E: Cannot instantiate protocol class "P" \
1630+ # N: Consider using "Callable[..., P]" instead of "type[P]"
16291631
16301632Alias = P
16311633GoodAlias = C
@@ -1646,14 +1648,16 @@ class C:
16461648 pass
16471649
16481650var: Type[P]
1649- var() # E: Cannot instantiate protocol class "P"
1651+ var() # E: Cannot instantiate protocol class "P" \
1652+ # N: Consider using "Callable[..., P]" instead of "type[P]"
16501653if int():
16511654 var = P # E: Can only assign concrete classes to a variable of type "Type[P]"
16521655 var = B # OK
16531656 var = C # OK
16541657
16551658var_old = None # type: Type[P] # Old syntax for variable annotations
1656- var_old() # E: Cannot instantiate protocol class "P"
1659+ var_old() # E: Cannot instantiate protocol class "P" \
1660+ # N: Consider using "Callable[..., P]" instead of "type[P]"
16571661if int():
16581662 var_old = P # E: Can only assign concrete classes to a variable of type "Type[P]"
16591663 var_old = B # OK
@@ -1669,7 +1673,8 @@ class Logger:
16691673class C(Protocol):
16701674 @classmethod
16711675 def action(cls) -> None:
1672- cls() # E: Cannot instantiate protocol class "C"
1676+ cls() # E: Cannot instantiate protocol class "C" \
1677+ # N: Consider using "Callable[..., C]" instead of "type[C]"
16731678 Logger.log(cls) #OK for classmethods
16741679[builtins fixtures/classmethod.pyi]
16751680
0 commit comments