Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ def visit_Call(self, e: Call) -> Type:

if not isinstance(self.parent(), ast3.List):
note = None
if constructor:
if constructor and not e.keywords:
note = "Suggestion: use {0}[...] instead of {0}(...)".format(constructor)
return self.invalid_type(e, note=note)
if not constructor:
Expand Down
9 changes: 9 additions & 0 deletions test-data/unit/check-fastparse.test
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ def f(a: Foo(int)) -> int:
main:7: error: Invalid type comment or annotation
main:7: note: Suggestion: use Foo[...] instead of Foo(...)

[case testFasterParseTypeErrorCustomNoSuggestionForKeywordArgs_no_native_parse]
from typing import TypeVar, Generic
T = TypeVar('T')
class Foo(Generic[T]):
pass
x: Foo(arg=1)
[out]
main:5: error: Invalid type comment or annotation

[case testFastParseMatMul]

from typing import Any
Expand Down
Loading