Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,9 @@ def validate_instance(t: Instance, fail: MsgCallback, empty_tuple_index: bool) -
arg_count = len(t.args)
min_tv_count = sum(not tv.has_default() for tv in t.type.defn.type_vars)
max_tv_count = len(t.type.type_vars)
if arg_count and (arg_count < min_tv_count or arg_count > max_tv_count):
if (arg_count or empty_tuple_index) and (
arg_count < min_tv_count or arg_count > max_tv_count
):
fail(
wrong_type_arg_count(min_tv_count, max_tv_count, str(arg_count), t.type.name),
t,
Expand Down
8 changes: 8 additions & 0 deletions test-data/unit/check-generics.test
Original file line number Diff line number Diff line change
Expand Up @@ -3622,3 +3622,11 @@ t2.foo = [B()]
t2.foo = [C()]
t2.foo = [1] # E: Value of type variable "T" of "foo" of "Test" cannot be "int"
[builtins fixtures/property.pyi]

[case testMissingTypeArgsInApplication]
Comment thread
A5rocks marked this conversation as resolved.
x: list[()] = [] # E: "list" expects 1 type argument, but none given

[case testMissingTypeArgsInApplicationStrict]
# flags: --strict
x: list[()] = [] # E: "list" expects 1 type argument, but none given \
# E: Missing type arguments for generic type "list"
Loading