Skip to content

Commit 10537c8

Browse files
committed
Fixes CI
1 parent a99b2f9 commit 10537c8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

classes/contrib/mypy/validation/validate_associated_type.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from mypy.plugin import MethodContext
2+
from mypy.typeops import get_type_vars
23
from mypy.types import CallableType, Instance
34
from typing_extensions import Final
45

@@ -95,13 +96,16 @@ def _check_generics(
9596
if not isinstance(instance_decl, Instance):
9697
return True
9798

98-
if len(instance_decl.args) != len(associated_type.type.type_vars):
99+
# We use `get_type_vars` here to exclude cases like `Supports[ToJson]`
100+
# and `List[int]` from validation:
101+
instance_args = get_type_vars(instance_decl)
102+
if len(instance_args) != len(associated_type.type.type_vars):
99103
ctx.api.fail(
100104
_GENERIC_MISSMATCH_MSG.format(
101105
associated_type.type.fullname,
102106
len(associated_type.type.type_vars),
103107
instance_decl,
104-
len(instance_decl.args),
108+
len(instance_args),
105109
),
106110
ctx.context,
107111
)

typesafety/test_typeclass/test_generics/test_generics_regular.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,5 @@
251251
252252
reveal_type(copy(a))
253253
out: |
254+
main:9: error: Generic type "main.Copy" with "0" type arguments does not match generic instance declaration "typing.Iterable[X`-1]" with "1" type arguments
254255
main:23: note: Revealed type is "<nothing>"

0 commit comments

Comments
 (0)